]> granicus.if.org Git - php/commitdiff
Use new param API in standard
authorSara Golemon <pollita@php.net>
Sat, 31 Dec 2016 01:09:35 +0000 (17:09 -0800)
committerSara Golemon <pollita@php.net>
Sat, 31 Dec 2016 01:28:55 +0000 (17:28 -0800)
ext/standard/info.c
ext/standard/iptc.c
ext/standard/link.c
ext/standard/mail.c
ext/standard/mt_rand.c
ext/standard/pack.c
ext/standard/password.c
ext/standard/string.c
ext/standard/uuencode.c

index 221b85464ae6a8dbf9793208811b7a932028ccca..865c5e98c1c54004c924a647f3b5b10522874360 100644 (file)
@@ -1267,9 +1267,10 @@ PHP_FUNCTION(phpinfo)
 {
        zend_long flag = PHP_INFO_ALL;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flag) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 1)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(flag)
+       ZEND_PARSE_PARAMETERS_END();
 
        /* Andale!  Andale!  Yee-Hah! */
        php_output_start_default();
@@ -1288,9 +1289,10 @@ PHP_FUNCTION(phpversion)
        char *ext_name = NULL;
        size_t ext_name_len = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &ext_name, &ext_name_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 1)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_STRING(ext_name, ext_name_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (!ext_name) {
                RETURN_STRING(PHP_VERSION);
@@ -1311,9 +1313,10 @@ PHP_FUNCTION(phpcredits)
 {
        zend_long flag = PHP_CREDITS_ALL;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flag) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 1)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(flag)
+       ZEND_PARSE_PARAMETERS_END();
 
        php_print_credits((int)flag);
        RETURN_TRUE;
@@ -1344,9 +1347,11 @@ PHP_FUNCTION(php_uname)
        char *mode = "a";
        size_t modelen = sizeof("a")-1;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &mode, &modelen) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 1)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_STRING(mode, modelen)
+       ZEND_PARSE_PARAMETERS_END();
+
        RETURN_STR(php_get_uname(*mode));
 }
 
index 04e51b00c1912b2be945f4606e2a9d5410c89ced..62b8473755eaea7d144ce90d34fae23064ae90c2 100644 (file)
@@ -197,9 +197,12 @@ PHP_FUNCTION(iptcembed)
        zend_stat_t sb;
        zend_bool written = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "sp|l", &iptcdata, &iptcdata_len, &jpeg_file, &jpeg_file_len, &spool) != SUCCESS) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 3)
+               Z_PARAM_STRING(iptcdata, iptcdata_len)
+               Z_PARAM_PATH(jpeg_file, jpeg_file_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(spool)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (php_check_open_basedir(jpeg_file)) {
                RETURN_FALSE;
@@ -321,9 +324,9 @@ PHP_FUNCTION(iptcparse)
        size_t str_len;
        zval values, *element;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &str, &str_len) != SUCCESS) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STRING(str, str_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        buffer = (unsigned char *)str;
 
index 62e7295c70ee04a2174c1dcb3ce5d88bf8cf80c7..e6b8220f50b18163cb575e76aae4629e6dfa1e37 100644 (file)
@@ -59,9 +59,9 @@ PHP_FUNCTION(readlink)
        char buff[MAXPATHLEN];
        int ret;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &link, &link_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_PATH(link, link_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (php_check_open_basedir(link)) {
                RETURN_FALSE;
@@ -90,9 +90,9 @@ PHP_FUNCTION(linkinfo)
        zend_stat_t sb;
        int ret;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &link, &link_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_PATH(link, link_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        dirname = estrndup(link, link_len);
        php_dirname(dirname, link_len);
@@ -126,9 +126,10 @@ PHP_FUNCTION(symlink)
        char dirname[MAXPATHLEN];
        size_t len;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 2)
+               Z_PARAM_PATH(topath, topath_len)
+               Z_PARAM_PATH(frompath, frompath_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (!expand_filepath(frompath, source_p)) {
                php_error_docref(NULL, E_WARNING, "No such file or directory");
@@ -182,9 +183,10 @@ PHP_FUNCTION(link)
        char source_p[MAXPATHLEN];
        char dest_p[MAXPATHLEN];
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 2)
+               Z_PARAM_PATH(topath, topath_len)
+               Z_PARAM_PATH(frompath, frompath_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (!expand_filepath(frompath, source_p) || !expand_filepath(topath, dest_p)) {
                php_error_docref(NULL, E_WARNING, "No such file or directory");
index fd05776787d3cd5f1a189a7e96cf506cfb86b401..8108225008cd465c2363ab32be67124e558cc114 100644 (file)
@@ -78,9 +78,9 @@ PHP_FUNCTION(ezmlm_hash)
        unsigned int h = 5381;
        size_t j, str_len;
 
-       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();
 
        for (j = 0; j < str_len; j++) {
                h = (h + (h << 5)) ^ (zend_ulong) (unsigned char) tolower(str[j]);
@@ -295,9 +295,14 @@ PHP_FUNCTION(mail)
        char *to_r, *subject_r;
        char *p, *e;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|zS", &to, &to_len, &subject, &subject_len, &message, &message_len, &headers, &extra_cmd) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(3, 5)
+               Z_PARAM_STRING(to, to_len)
+               Z_PARAM_STRING(subject, subject_len)
+               Z_PARAM_STRING(message, message_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_ZVAL_DEREF(headers)
+               Z_PARAM_STR(extra_cmd)
+       ZEND_PARSE_PARAMETERS_END();
 
        /* ASCIIZ check */
        MAIL_ASCIIZ_CHECK(to, to_len);
index dde9a771349d9231d155fe27fda81936a9931ba0..80ec01c02737eb807eda5b539144090bfde4a30e 100644 (file)
@@ -191,8 +191,11 @@ PHP_FUNCTION(mt_srand)
        zend_long seed = 0;
        zend_long mode = MT_RAND_MT19937;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ll", &seed, &mode) == FAILURE)
-               return;
+       ZEND_PARSE_PARAMETERS_START(0, 2)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(seed)
+               Z_PARAM_LONG(mode)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (ZEND_NUM_ARGS() == 0)
                seed = GENERATE_SEED();
@@ -288,9 +291,10 @@ PHP_FUNCTION(mt_rand)
                RETURN_LONG(php_mt_rand() >> 1);
        }
 
-       if (zend_parse_parameters(argc, "ll", &min, &max) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 2)
+               Z_PARAM_LONG(min)
+               Z_PARAM_LONG(max)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (UNEXPECTED(max < min)) {
                php_error_docref(NULL, E_WARNING, "max(" ZEND_LONG_FMT ") is smaller than min(" ZEND_LONG_FMT ")", max, min);
index 1c13f0be96fadd518f41ab77a5000eba995f77c1..447b0ee9cfdc1b6eef5e4a0edd8e4365790e56a2 100644 (file)
@@ -116,9 +116,10 @@ PHP_FUNCTION(pack)
        int outputpos = 0, outputsize = 0;
        zend_string *output;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s*", &format, &formatlen, &argv, &num_args) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, -1)
+               Z_PARAM_STRING(format, formatlen)
+               Z_PARAM_VARIADIC('*', argv, num_args)
+       ZEND_PARSE_PARAMETERS_END();
 
        /* We have a maximum of <formatlen> format codes to deal with */
        formatcodes = safe_emalloc(formatlen, sizeof(*formatcodes), 0);
@@ -547,10 +548,12 @@ PHP_FUNCTION(unpack)
        int i;
        zend_long offset = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|l", &formatarg,
-               &inputarg, &offset) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 3)
+               Z_PARAM_STR(formatarg)
+               Z_PARAM_STR(inputarg)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(offset)
+       ZEND_PARSE_PARAMETERS_END();
 
        format = ZSTR_VAL(formatarg);
        formatlen = ZSTR_LEN(formatarg);
index d362e6f7f3712feccbb97a2e897703a1f280c98f..c5b5fe2c98a37f338220ae7e57d3222dc3601fd6 100644 (file)
@@ -173,9 +173,9 @@ PHP_FUNCTION(password_get_info)
        char *hash, *algo_name;
        zval options;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &hash, &hash_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STRING(hash, hash_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        array_init(&options);
 
@@ -229,9 +229,12 @@ PHP_FUNCTION(password_needs_rehash)
        HashTable *options = 0;
        zval *option_buffer;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|H", &hash, &hash_len, &new_algo, &options) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 3)
+               Z_PARAM_STRING(hash, hash_len)
+               Z_PARAM_LONG(new_algo)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_ARRAY_OR_OBJECT_HT(options)
+       ZEND_PARSE_PARAMETERS_END();
 
        algo = php_password_determine_algo(hash, (size_t) hash_len);
 
@@ -300,9 +303,10 @@ PHP_FUNCTION(password_verify)
        zend_string *ret;
        php_password_algo algo;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &password, &password_len, &hash, &hash_len) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 2)
+               Z_PARAM_STRING(password, password_len)
+               Z_PARAM_STRING(hash, hash_len)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        algo = php_password_determine_algo(hash, (size_t) hash_len);
 
@@ -372,9 +376,12 @@ PHP_FUNCTION(password_hash)
        argon2_type type = Argon2_i;
 #endif
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|H", &password, &password_len, &algo, &options) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 3)
+               Z_PARAM_STRING(password, password_len)
+               Z_PARAM_LONG(algo)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_ARRAY_OR_OBJECT_HT(options)
+       ZEND_PARSE_PARAMETERS_END();
 
        switch (algo) {
                case PHP_PASSWORD_BCRYPT:
index a4bb111caab2a91bc28161f2d3f07489390983aa..845855ad4cd4423e94205c3b440c2c693b849528 100644 (file)
@@ -4981,7 +4981,7 @@ PHP_FUNCTION(str_repeat)
 
        ZEND_PARSE_PARAMETERS_START(2, 2)
                Z_PARAM_STR(input_str)
-               Z_PARMA_LONG(mult)
+               Z_PARAM_LONG(mult)
        ZEND_PARSE_PARAMETERS_END();
 
        if (mult < 0) {
@@ -5038,7 +5038,7 @@ PHP_FUNCTION(count_chars)
        ZEND_PARSE_PARAMETERS_START(1, 2)
                Z_PARAM_STR(input)
                Z_PARAM_OPTIONAL
-               Z_PARMA_LONG(mymode)
+               Z_PARAM_LONG(mymode)
        ZEND_PARSE_PARAMETERS_END();
 
        if (mymode < 0 || mymode > 4) {
index 787569e430dab5c89bb381317a427cb056e4ab80..a99a98d35f29516d5a6fbf759f4a495f3282fc4f 100644 (file)
@@ -204,9 +204,10 @@ PHP_FUNCTION(convert_uuencode)
 {
        zend_string *src;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &src) == FAILURE || ZSTR_LEN(src) < 1) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STR(src)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+       if (ZSTR_LEN(src) < 1) { RETURN_FALSE; }
 
        RETURN_STR(php_uuencode(ZSTR_VAL(src), ZSTR_LEN(src)));
 }
@@ -219,9 +220,10 @@ PHP_FUNCTION(convert_uudecode)
        zend_string *src;
        zend_string *dest;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &src) == FAILURE || ZSTR_LEN(src) < 1) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STR(src)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+       if (ZSTR_LEN(src) < 1) { RETURN_FALSE; }
 
        if ((dest = php_uudecode(ZSTR_VAL(src), ZSTR_LEN(src))) == NULL) {
                php_error_docref(NULL, E_WARNING, "The given parameter is not a valid uuencoded string");