diff options
Diffstat (limited to 'ext/standard')
-rw-r--r-- | ext/standard/ftok.c | 18 | ||||
-rw-r--r-- | ext/standard/image.c | 50 | ||||
-rw-r--r-- | ext/standard/info.c | 11 | ||||
-rw-r--r-- | ext/standard/pack.c | 27 | ||||
-rw-r--r-- | ext/standard/quot_print.c | 14 | ||||
-rw-r--r-- | ext/standard/streamsfuncs.c | 63 | ||||
-rwxr-xr-x | ext/standard/tests/file/stream_rfc2397_002.phpt | 14 | ||||
-rw-r--r-- | ext/standard/tests/general_functions/floatval.phpt | 8 | ||||
-rw-r--r-- | ext/standard/tests/general_functions/gettype_settype_error.phpt | 8 | ||||
-rw-r--r-- | ext/standard/tests/general_functions/strval.phpt | 4 | ||||
-rw-r--r-- | ext/standard/tests/serialize/serialization_error_001.phpt | 6 | ||||
-rw-r--r-- | ext/standard/tests/streams/stream_get_meta_data_file_error.phpt | 8 | ||||
-rw-r--r-- | ext/standard/tests/streams/stream_set_timeout_error.phpt | 8 | ||||
-rw-r--r-- | ext/standard/var.c | 4 |
14 files changed, 108 insertions, 135 deletions
diff --git a/ext/standard/ftok.c b/ext/standard/ftok.c index f9ef6adf9d..7298a8db61 100644 --- a/ext/standard/ftok.c +++ b/ext/standard/ftok.c @@ -31,31 +31,29 @@ Convert a pathname and a project identifier to a System V IPC key */ PHP_FUNCTION(ftok) { - zval **pathname, **proj; + char *pathname, *proj; + int pathname_len, proj_len; key_t k; - if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &pathname, &proj) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, &pathname, &pathname_len, &proj, &proj_len) == FAILURE) { + return; } - convert_to_string_ex(pathname); - convert_to_string_ex(proj); - - if (Z_STRLEN_PP(pathname)==0){ + if (pathname_len == 0){ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Pathname is invalid"); RETURN_LONG(-1); } - if (Z_STRLEN_PP(proj)!=1){ + if (proj_len != 1){ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Project identifier is invalid"); RETURN_LONG(-1); } - if ((PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(pathname), NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(Z_STRVAL_PP(pathname) TSRMLS_CC)) { + if ((PG(safe_mode) && (!php_checkuid(pathname, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(pathname TSRMLS_CC)) { RETURN_LONG(-1); } - k = ftok(Z_STRVAL_PP(pathname),Z_STRVAL_PP(proj)[0]); + k = ftok(pathname, proj[0]); if (k == -1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "ftok() failed - %s", strerror(errno)); } diff --git a/ext/standard/image.c b/ext/standard/image.c index e1fe1a14e8..c2f640ed45 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -1160,15 +1160,13 @@ PHPAPI char * php_image_type_to_mime_type(int image_type) Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype */ PHP_FUNCTION(image_type_to_mime_type) { - zval **p_image_type; - int arg_c = ZEND_NUM_ARGS(); + long p_image_type; - if ((arg_c!=1) || zend_get_parameters_ex(arg_c, &p_image_type) == FAILURE) { - RETVAL_FALSE; - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &p_image_type) == FAILURE) { + return; } - convert_to_long_ex(p_image_type); - ZVAL_STRING(return_value, (char*)php_image_type_to_mime_type(Z_LVAL_PP(p_image_type)), 1); + + ZVAL_STRING(return_value, (char*)php_image_type_to_mime_type(p_image_type), 1); } /* }}} */ @@ -1300,40 +1298,22 @@ PHPAPI int php_getimagetype(php_stream * stream, char *filetype TSRMLS_DC) Get the size of an image as 4-element array */ PHP_FUNCTION(getimagesize) { - zval **arg1, **info = NULL; - int itype = 0; - char *temp; + zval **info = NULL; + char *arg1, *temp; + int arg1_len, itype = 0, argc = ZEND_NUM_ARGS(); struct gfxinfo *result = NULL; php_stream * stream = NULL; - switch(ZEND_NUM_ARGS()) { - - case 1: - if (zend_get_parameters_ex(1, &arg1) == FAILURE) { - RETVAL_FALSE; - WRONG_PARAM_COUNT; - } - convert_to_string_ex(arg1); - break; - - case 2: - if (zend_get_parameters_ex(2, &arg1, &info) == FAILURE) { - RETVAL_FALSE; - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(argc TSRMLS_CC, "s|Z", &arg1, &arg1_len, &info) == FAILURE) { + return; + } + + if (argc == 2) { zval_dtor(*info); - array_init(*info); - - convert_to_string_ex(arg1); - break; - - default: - RETVAL_FALSE; - WRONG_PARAM_COUNT; } - stream = php_stream_open_wrapper(Z_STRVAL_PP(arg1), "rb", STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE, NULL); + stream = php_stream_open_wrapper(arg1, "rb", STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE, NULL); if (!stream) { RETURN_FALSE; @@ -1342,7 +1322,7 @@ PHP_FUNCTION(getimagesize) itype = php_getimagetype(stream, NULL TSRMLS_CC); switch( itype) { case IMAGE_FILETYPE_GIF: - result = php_handle_gif (stream TSRMLS_CC); + result = php_handle_gif(stream TSRMLS_CC); break; case IMAGE_FILETYPE_JPEG: if (info) { diff --git a/ext/standard/info.c b/ext/standard/info.c index 1378512cd7..5a76604241 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -1033,20 +1033,23 @@ PHP_FUNCTION(phpinfo) PHP_FUNCTION(phpversion) { zval **arg; + const char *version; int argc = ZEND_NUM_ARGS(); if (argc == 0) { RETURN_STRING(PHP_VERSION, 1); - } else if (argc == 1 && zend_get_parameters_ex(1, &arg) == SUCCESS) { - const char *version; + } else { + if (zend_parse_parameters(argc TSRMLS_CC, "Z", &arg) == FAILURE) { + return; + } + convert_to_string_ex(arg); version = zend_get_module_version(Z_STRVAL_PP(arg)); + if (version == NULL) { RETURN_FALSE; } RETURN_STRING(version, 1); - } else { - WRONG_PARAM_COUNT; } } /* }}} */ diff --git a/ext/standard/pack.c b/ext/standard/pack.c index 5707544009..48bdc879df 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -514,26 +514,19 @@ static long php_unpack(char *data, int size, int issigned, int *map) Unpack binary string into named array elements according to format argument */ PHP_FUNCTION(unpack) { - zval **formatarg; - zval **inputarg; - char *format; - char *input; - int formatlen; - int inputpos, inputlen; - int i; + char *format, *input, *formatarg, *inputarg; + int formatlen, formatarg_len, inputarg_len; + int inputpos, inputlen, i; - if (ZEND_NUM_ARGS() != 2 || - zend_get_parameters_ex(2, &formatarg, &inputarg) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &formatarg, &formatarg_len, + &inputarg, &inputarg_len) == FAILURE) { + return; } - convert_to_string_ex(formatarg); - convert_to_string_ex(inputarg); - - format = Z_STRVAL_PP(formatarg); - formatlen = Z_STRLEN_PP(formatarg); - input = Z_STRVAL_PP(inputarg); - inputlen = Z_STRLEN_PP(inputarg); + format = formatarg; + formatlen = formatarg_len; + input = inputarg; + inputlen = inputarg_len; inputpos = 0; array_init(return_value); diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c index 48f0f77c69..a1e537940d 100644 --- a/ext/standard/quot_print.c +++ b/ext/standard/quot_print.c @@ -151,22 +151,20 @@ PHPAPI unsigned char *php_quot_print_decode(const unsigned char *str, size_t len Convert a quoted-printable string to an 8 bit string */ PHP_FUNCTION(quoted_printable_decode) { - zval **arg1; - char *str_in, *str_out; - int i = 0, j = 0, k; + char *arg1, *str_in, *str_out; + int arg1_len, i = 0, j = 0, k; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg1, &arg1_len) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_string_ex(arg1); - if (Z_STRLEN_PP(arg1) == 0) { + if (arg1_len == 0) { /* shortcut */ RETURN_EMPTY_STRING(); } - str_in = Z_STRVAL_PP(arg1); - str_out = emalloc(Z_STRLEN_PP(arg1) + 1); + str_in = arg1; + str_out = emalloc(arg1_len + 1); while (str_in[i]) { switch (str_in[i]) { case '=': diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 80fe31c5b0..6649ec4cd6 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -454,14 +454,14 @@ PHP_FUNCTION(stream_copy_to_stream) Retrieves header/meta data from streams/file pointers */ PHP_FUNCTION(stream_get_meta_data) { - zval **arg1; + zval *arg1; php_stream *stream; zval *newval; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + return; } - php_stream_from_zval(stream, arg1); + php_stream_from_zval(stream, &arg1); array_init(return_value); @@ -1219,52 +1219,53 @@ PHP_FUNCTION(stream_get_line) Set blocking/non-blocking mode on a socket or stream */ PHP_FUNCTION(stream_set_blocking) { - zval **arg1, **arg2; + zval *arg1; int block; + long arg2; php_stream *stream; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &arg2) == FAILURE) { + return; } - php_stream_from_zval(stream, arg1); + php_stream_from_zval(stream, &arg1); - convert_to_long_ex(arg2); - block = Z_LVAL_PP(arg2); + block = arg2; - if (php_stream_set_option(stream, PHP_STREAM_OPTION_BLOCKING, block == 0 ? 0 : 1, NULL) == -1) + if (php_stream_set_option(stream, PHP_STREAM_OPTION_BLOCKING, block == 0 ? 0 : 1, NULL) == -1) { RETURN_FALSE; + } + RETURN_TRUE; } /* }}} */ -/* {{{ proto bool stream_set_timeout(resource stream, int seconds, int microseconds) +/* {{{ proto bool stream_set_timeout(resource stream, int seconds [, int microseconds]) Set timeout on stream read to seconds + microseonds */ #if HAVE_SYS_TIME_H || defined(PHP_WIN32) PHP_FUNCTION(stream_set_timeout) { - zval **socket, **seconds, **microseconds; + zval *socket; + long seconds, microseconds; struct timeval t; php_stream *stream; + int argc = ZEND_NUM_ARGS(); - if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > 3 || - zend_get_parameters_ex(ZEND_NUM_ARGS(), &socket, &seconds, µseconds)==FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(argc TSRMLS_CC, "rl|l", &socket, &seconds, µseconds) == FAILURE) { + return; } - php_stream_from_zval(stream, socket); + php_stream_from_zval(stream, &socket); - convert_to_long_ex(seconds); - t.tv_sec = Z_LVAL_PP(seconds); + t.tv_sec = seconds; - if (ZEND_NUM_ARGS() == 3) { - convert_to_long_ex(microseconds); - t.tv_usec = Z_LVAL_PP(microseconds) % 1000000; - t.tv_sec += Z_LVAL_PP(microseconds) / 1000000; - } - else + if (argc == 3) { + t.tv_usec = microseconds % 1000000; + t.tv_sec += microseconds / 1000000; + } else { t.tv_usec = 0; + } if (PHP_STREAM_OPTION_RETURN_OK == php_stream_set_option(stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &t)) { RETURN_TRUE; @@ -1279,14 +1280,15 @@ PHP_FUNCTION(stream_set_timeout) Set file write buffer */ PHP_FUNCTION(stream_set_write_buffer) { - zval **arg1, **arg2; + zval *arg1; int ret; + long arg2; size_t buff; php_stream *stream; switch (ZEND_NUM_ARGS()) { case 2: - if (zend_get_parameters_ex(2, &arg1, &arg2)==FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &arg2) == FAILURE) { RETURN_FALSE; } break; @@ -1296,10 +1298,9 @@ PHP_FUNCTION(stream_set_write_buffer) break; } - php_stream_from_zval(stream, arg1); - - convert_to_long_ex(arg2); - buff = Z_LVAL_PP(arg2); + php_stream_from_zval(stream, &arg1); + + buff = arg2; /* if buff is 0 then set to non-buffered */ if (buff == 0) { diff --git a/ext/standard/tests/file/stream_rfc2397_002.phpt b/ext/standard/tests/file/stream_rfc2397_002.phpt index b75d372d87..980863bb5c 100755 --- a/ext/standard/tests/file/stream_rfc2397_002.phpt +++ b/ext/standard/tests/file/stream_rfc2397_002.phpt @@ -52,7 +52,7 @@ array(7) { NULL Warning: fopen(data://): failed to open stream: rfc2397: no comma in URL in %sstream_rfc2397_002.php on line %d -bool(false) +NULL NULL array(7) { ["wrapper_type"]=> @@ -73,15 +73,15 @@ array(7) { NULL Warning: fopen(data://;base64): failed to open stream: rfc2397: no comma in URL in %sstream_rfc2397_002.php on line %d -bool(false) +NULL NULL Warning: fopen(data://foo,): failed to open stream: rfc2397: illegal media type in %sstream_rfc2397_002.php on line %d -bool(false) +NULL NULL Warning: fopen(data://foo=bar,): failed to open stream: rfc2397: illegal media type in %sstream_rfc2397_002.php on line %d -bool(false) +NULL NULL array(8) { ["wrapper_type"]=> @@ -104,7 +104,7 @@ array(8) { NULL Warning: fopen(data://text/plain;foo,): failed to open stream: rfc2397: illegal parameter in %sstream_rfc2397_002.php on line %d -bool(false) +NULL NULL array(9) { ["wrapper_type"]=> @@ -129,7 +129,7 @@ array(9) { string(3) "bar" Warning: fopen(data://text/plain;foo=bar;bla,): failed to open stream: rfc2397: illegal parameter in %sstream_rfc2397_002.php on line %d -bool(false) +NULL NULL array(9) { ["wrapper_type"]=> @@ -154,7 +154,7 @@ array(9) { string(3) "bar" Warning: fopen(data://text/plain;foo=bar;bar=baz): failed to open stream: rfc2397: no comma in URL in %sstream_rfc2397_002.php on line %d -bool(false) +NULL NULL array(10) { ["wrapper_type"]=> diff --git a/ext/standard/tests/general_functions/floatval.phpt b/ext/standard/tests/general_functions/floatval.phpt index bb28368e24..b427bda7d5 100644 --- a/ext/standard/tests/general_functions/floatval.phpt +++ b/ext/standard/tests/general_functions/floatval.phpt @@ -192,16 +192,16 @@ float(0) *** Testing error conditions *** -Warning: Wrong parameter count for floatval() in %s on line %d +Warning: floatval() expects exactly 1 parameter, 0 given in %s on line %d NULL -Warning: Wrong parameter count for doubleval() in %s on line %d +Warning: doubleval() expects exactly 1 parameter, 0 given in %s on line %d NULL -Warning: Wrong parameter count for floatval() in %s on line %d +Warning: floatval() expects exactly 1 parameter, 2 given in %s on line %d NULL -Warning: Wrong parameter count for doubleval() in %s on line %d +Warning: doubleval() expects exactly 1 parameter, 2 given in %s on line %d NULL Done diff --git a/ext/standard/tests/general_functions/gettype_settype_error.phpt b/ext/standard/tests/general_functions/gettype_settype_error.phpt index 3a61842daa..2c6aac6875 100644 --- a/ext/standard/tests/general_functions/gettype_settype_error.phpt +++ b/ext/standard/tests/general_functions/gettype_settype_error.phpt @@ -37,18 +37,18 @@ echo "Done\n"; *** Testing gettype(): error conditions *** -Warning: Wrong parameter count for gettype() in %s on line %d +Warning: gettype() expects exactly 1 parameter, 0 given in %s on line %d NULL -Warning: Wrong parameter count for gettype() in %s on line %d +Warning: gettype() expects exactly 1 parameter, 2 given in %s on line %d NULL *** Testing settype(): error conditions *** -Warning: Wrong parameter count for settype() in %s on line %d +Warning: settype() expects exactly 2 parameters, 0 given in %s on line %d NULL -Warning: Wrong parameter count for settype() in %s on line %d +Warning: settype() expects exactly 2 parameters, 3 given in %s on line %d NULL Warning: settype(): Invalid type in %s on line %d diff --git a/ext/standard/tests/general_functions/strval.phpt b/ext/standard/tests/general_functions/strval.phpt index 8cf827303d..bcaa5b90f0 100644 --- a/ext/standard/tests/general_functions/strval.phpt +++ b/ext/standard/tests/general_functions/strval.phpt @@ -302,9 +302,9 @@ string(0) "" *** Testing error conditions *** -Warning: Wrong parameter count for strval() in %s on line %d +Warning: strval() expects exactly 1 parameter, 0 given in %s on line %d NULL -Warning: Wrong parameter count for strval() in %s on line %d +Warning: strval() expects exactly 1 parameter, 2 given in %s on line %d NULL Done diff --git a/ext/standard/tests/serialize/serialization_error_001.phpt b/ext/standard/tests/serialize/serialization_error_001.phpt index 3f530580d6..da6f50cc02 100644 --- a/ext/standard/tests/serialize/serialization_error_001.phpt +++ b/ext/standard/tests/serialize/serialization_error_001.phpt @@ -28,15 +28,15 @@ echo "Done"; --EXPECTF-- *** Testing serialize()/unserialize() : error conditions *** -Warning: Wrong parameter count for serialize() in %s on line 16 +Warning: serialize() expects exactly 1 parameter, 0 given in %s on line 16 NULL Warning: unserialize() expects exactly 1 parameter, 0 given in %s on line 17 bool(false) -Warning: Wrong parameter count for serialize() in %s on line 20 +Warning: serialize() expects exactly 1 parameter, 2 given in %s on line 20 NULL Warning: unserialize() expects exactly 1 parameter, 2 given in %s on line 21 bool(false) -Done
\ No newline at end of file +Done diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_error.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_error.phpt index 912c4055a2..390694a062 100644 --- a/ext/standard/tests/streams/stream_get_meta_data_file_error.phpt +++ b/ext/standard/tests/streams/stream_get_meta_data_file_error.phpt @@ -37,18 +37,18 @@ echo "Done"; -- Testing stream_get_meta_data() function with Zero arguments -- -Warning: Wrong parameter count for stream_get_meta_data() in %s on line %i +Warning: stream_get_meta_data() expects exactly 1 parameter, 0 given in %s on line %i NULL -- Testing stream_get_meta_data() function with more than expected no. of arguments -- -Warning: Wrong parameter count for stream_get_meta_data() in %s on line %i +Warning: stream_get_meta_data() expects exactly 1 parameter, 2 given in %s on line %i NULL -- Testing stream_get_meta_data() function with invalid stream resource -- -Warning: stream_get_meta_data(): supplied argument is not a valid stream resource in %s on line %i -bool(false) +Warning: stream_get_meta_data() expects parameter 1 to be resource, null given in %s on line %i +NULL -- Testing stream_get_meta_data() function with closed stream resource -- diff --git a/ext/standard/tests/streams/stream_set_timeout_error.phpt b/ext/standard/tests/streams/stream_set_timeout_error.phpt index 1e8e60bd2a..e2c17c0187 100644 --- a/ext/standard/tests/streams/stream_set_timeout_error.phpt +++ b/ext/standard/tests/streams/stream_set_timeout_error.phpt @@ -56,12 +56,12 @@ echo "Done"; -- Testing stream_set_timeout() function with more than expected no. of arguments -- -Warning: Wrong parameter count for stream_set_timeout() in %s on line %i +Warning: stream_set_timeout() expects at most 3 parameters, 4 given in %s on line %i NULL -- Testing stream_set_timeout() function with less than expected no. of arguments -- -Warning: Wrong parameter count for stream_set_timeout() in %s on line %i +Warning: stream_set_timeout() expects at least 2 parameters, 1 given in %s on line %i NULL -- Testing stream_set_timeout() function with a closed socket -- @@ -71,8 +71,8 @@ bool(false) -- Testing stream_set_timeout() function with an invalid stream -- -Warning: stream_set_timeout(): supplied argument is not a valid stream resource in %s on line %i -bool(false) +Warning: stream_set_timeout() expects parameter 1 to be resource, integer given in %s on line %i +NULL -- Testing stream_set_timeout() function with a stream that does not support timeouts -- bool(false) diff --git a/ext/standard/var.c b/ext/standard/var.c index 6000672b98..8b52516776 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -838,8 +838,8 @@ PHP_FUNCTION(serialize) php_serialize_data_t var_hash; smart_str buf = {0}; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &struc) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &struc) == FAILURE) { + return; } Z_TYPE_P(return_value) = IS_STRING; |