mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Use new param API in standard
This commit is contained in:
parent
c9a42b58a7
commit
6f3945a9f1
7 changed files with 61 additions and 48 deletions
|
@ -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:
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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, "e_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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue