diff options
-rw-r--r-- | ext/interbase/ibase_blobs.c | 2 | ||||
-rw-r--r-- | ext/interbase/ibase_query.c | 14 | ||||
-rw-r--r-- | ext/interbase/ibase_service.c | 9 | ||||
-rw-r--r-- | ext/interbase/interbase.c | 2 | ||||
-rw-r--r-- | ext/intl/calendar/calendar_methods.cpp | 12 | ||||
-rw-r--r-- | ext/intl/grapheme/grapheme_string.c | 4 | ||||
-rw-r--r-- | ext/intl/tests/calendar_isWeekend_error.phpt | 1 | ||||
-rw-r--r-- | ext/mbstring/mbstring.c | 72 | ||||
-rw-r--r-- | ext/mbstring/php_mbregex.c | 20 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg.c | 12 |
10 files changed, 64 insertions, 84 deletions
diff --git a/ext/interbase/ibase_blobs.c b/ext/interbase/ibase_blobs.c index ba384f8cd2..d492f55f7a 100644 --- a/ext/interbase/ibase_blobs.c +++ b/ext/interbase/ibase_blobs.c @@ -318,7 +318,7 @@ PHP_FUNCTION(ibase_blob_add) PHP_FUNCTION(ibase_blob_get) { zval *blob_arg; - unsigned long len_arg; + zend_ulong len_arg; ibase_blob *ib_blob; RESET_ERRMSG; diff --git a/ext/interbase/ibase_query.c b/ext/interbase/ibase_query.c index 43fa760833..fce9206dd7 100644 --- a/ext/interbase/ibase_query.c +++ b/ext/interbase/ibase_query.c @@ -1061,7 +1061,8 @@ PHP_FUNCTION(ibase_query) { zval *zlink, *ztrans, *bind_args = NULL; char *query; - int bind_i, query_len, bind_num; + size_t query_len; + int bind_i, bind_num; long trans_res_id = 0; ibase_db_link *ib_link = NULL; ibase_trans *trans = NULL; @@ -1073,7 +1074,7 @@ PHP_FUNCTION(ibase_query) RETVAL_FALSE; switch (ZEND_NUM_ARGS()) { - long l; + zend_long l; default: if (SUCCESS == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, 3, "rrs", @@ -1472,7 +1473,8 @@ static int _php_ibase_arr_zval(zval *ar_zval, char *data, unsigned long data_siz static void _php_ibase_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int fetch_type) /* {{{ */ { zval *result_arg; - long i, array_cnt = 0, flag = 0; + zend_long flag = 0; + long i, array_cnt = 0; ibase_result *ib_result; RESET_ERRMSG; @@ -1684,7 +1686,7 @@ PHP_FUNCTION(ibase_name_result) { zval *result_arg; char *name_arg; - int name_arg_len; + size_t name_arg_len; ibase_result *ib_result; RESET_ERRMSG; @@ -1998,7 +2000,7 @@ static void _php_ibase_field_info(zval *return_value, XSQLVAR *var) /* {{{ */ PHP_FUNCTION(ibase_field_info) { zval *result_arg; - long field_arg; + zend_long field_arg; int type; XSQLDA *sqlda; @@ -2062,7 +2064,7 @@ PHP_FUNCTION(ibase_num_params) PHP_FUNCTION(ibase_param_info) { zval *result_arg; - long field_arg; + zend_long field_arg; ibase_query *ib_query; RESET_ERRMSG; diff --git a/ext/interbase/ibase_service.c b/ext/interbase/ibase_service.c index 53795f6668..628d4575f0 100644 --- a/ext/interbase/ibase_service.c +++ b/ext/interbase/ibase_service.c @@ -425,7 +425,7 @@ static void _php_ibase_backup_restore(INTERNAL_FUNCTION_PARAMETERS, char operati zval *res; char *db, *bk, buf[200]; size_t dblen, bklen, spb_len; - long opts = 0; + zend_long opts = 0; zend_bool verbose = 0; ibase_service *svm; @@ -488,8 +488,9 @@ static void _php_ibase_service_action(INTERNAL_FUNCTION_PARAMETERS, char svc_act { zval *res; char buf[128], *db; - int dblen, spb_len; - long action, argument = 0; + size_t dblen; + int spb_len; + zend_long action, argument = 0; ibase_service *svm; RESET_ERRMSG; @@ -596,7 +597,7 @@ PHP_FUNCTION(ibase_db_info) PHP_FUNCTION(ibase_server_info) { zval *res; - long action; + zend_long action; ibase_service *svm; RESET_ERRMSG; diff --git a/ext/interbase/interbase.c b/ext/interbase/interbase.c index 919ea7de5e..cb6baad658 100644 --- a/ext/interbase/interbase.c +++ b/ext/interbase/interbase.c @@ -1421,7 +1421,7 @@ PHP_FUNCTION(ibase_gen_id) zval *link = NULL; char query[128], *generator; size_t gen_len; - long inc = 1; + zend_long inc = 1; ibase_db_link *ib_link; ibase_trans *trans = NULL; XSQLDA out_sqlda; diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp index ac5b33a89c..adeae6b222 100644 --- a/ext/intl/calendar/calendar_methods.cpp +++ b/ext/intl/calendar/calendar_methods.cpp @@ -923,15 +923,11 @@ U_CFUNC PHP_FUNCTION(intlcal_is_set) U_CFUNC PHP_FUNCTION(intlcal_is_weekend) { double date; - zval *rawDate = NULL; + zend_bool date_is_null = 1; CALENDAR_METHOD_INIT_VARS; - if (zend_parse_method_parameters_ex(ZEND_PARSE_PARAMS_QUIET, - ZEND_NUM_ARGS(), getThis(), - "O|z!", &object, Calendar_ce_ptr, &rawDate) == FAILURE - || (rawDate != NULL && - zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), - "O|d", &object, Calendar_ce_ptr, &date) == FAILURE)) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), + "O|d!", &object, Calendar_ce_ptr, &date, &date_is_null) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intlcal_is_weekend: bad arguments", 0); RETURN_FALSE; @@ -939,7 +935,7 @@ U_CFUNC PHP_FUNCTION(intlcal_is_weekend) CALENDAR_METHOD_FETCH_OBJECT; - if (rawDate == NULL) { + if (date_is_null) { RETURN_BOOL((int)co->ucal->isWeekend()); } else { UBool ret = co->ucal->isWeekend((UDate)date, CALENDAR_ERROR_CODE(co)); diff --git a/ext/intl/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.c index c38d51aa78..f42ba7e69e 100644 --- a/ext/intl/grapheme/grapheme_string.c +++ b/ext/intl/grapheme/grapheme_string.c @@ -383,9 +383,9 @@ PHP_FUNCTION(grapheme_substr) UBreakIterator* bi = NULL; int sub_str_start_pos, sub_str_end_pos; int32_t (*iter_func)(UBreakIterator *); - int no_length = 1; + zend_bool no_length = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|l!", (char **)&str, &str_len, &lstart, &length, &no_length) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|l!", &str, &str_len, &lstart, &length, &no_length) == FAILURE) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr: unable to parse input param", 0 ); RETURN_FALSE; diff --git a/ext/intl/tests/calendar_isWeekend_error.phpt b/ext/intl/tests/calendar_isWeekend_error.phpt index 8f723cc3c9..417bcb4c23 100644 --- a/ext/intl/tests/calendar_isWeekend_error.phpt +++ b/ext/intl/tests/calendar_isWeekend_error.phpt @@ -21,6 +21,7 @@ var_dump(intlcal_is_weekend($c, "jj")); var_dump(intlcal_is_weekend(1)); --EXPECTF-- +Warning: IntlCalendar::isWeekend() expects at most 1 parameter, 2 given in %s on line %d Warning: IntlCalendar::isWeekend(): intlcal_is_weekend: bad arguments in %s on line %d bool(false) diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index ea753b9406..c0c622a51e 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -2255,7 +2255,7 @@ PHP_FUNCTION(mb_strlen) PHP_FUNCTION(mb_strpos) { int n, reverse = 0; - zend_long offset; + zend_long offset = 0; mbfl_string haystack, needle; char *enc_name = NULL; size_t enc_name_len; @@ -2266,7 +2266,6 @@ PHP_FUNCTION(mb_strpos) haystack.no_encoding = MBSTRG(current_internal_encoding)->no_encoding; needle.no_language = MBSTRG(language); needle.no_encoding = MBSTRG(current_internal_encoding)->no_encoding; - offset = 0; if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|ls", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &offset, &enc_name, &enc_name_len) == FAILURE) { return; @@ -2416,13 +2415,11 @@ PHP_FUNCTION(mb_strrpos) Finds position of first occurrence of a string within another, case insensitive */ PHP_FUNCTION(mb_stripos) { - int n; - zend_long offset; + int n = -1; + zend_long offset = 0; mbfl_string haystack, needle; const char *from_encoding = MBSTRG(current_internal_encoding)->mime_name; size_t from_encoding_len; - n = -1; - offset = 0; if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|ls", (char **)&haystack.val, (int *)&haystack.len, (char **)&needle.val, (int *)&needle.len, &offset, &from_encoding, &from_encoding_len) == FAILURE) { return; @@ -2445,13 +2442,11 @@ PHP_FUNCTION(mb_stripos) Finds position of last occurrence of a string within another, case insensitive */ PHP_FUNCTION(mb_strripos) { - int n; - zend_long offset; + int n = -1; + zend_long offset = 0; mbfl_string haystack, needle; const char *from_encoding = MBSTRG(current_internal_encoding)->mime_name; size_t from_encoding_len; - n = -1; - offset = 0; if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|ls", (char **)&haystack.val, (int *)&haystack.len, (char **)&needle.val, (int *)&needle.len, &offset, &from_encoding, &from_encoding_len) == FAILURE) { return; @@ -2760,15 +2755,14 @@ PHP_FUNCTION(mb_substr_count) Returns part of a string */ PHP_FUNCTION(mb_substr) { - size_t argc = ZEND_NUM_ARGS(); - char *str, *encoding; + char *str, *encoding = NULL; zend_long from, len; int mblen; size_t str_len, encoding_len; - zval *z_len = NULL; + zend_bool len_is_null = 1; mbfl_string string, result, *ret; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|zs", &str, &str_len, &from, &z_len, &encoding, &encoding_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|l!s", &str, &str_len, &from, &len, &len_is_null, &encoding, &encoding_len) == FAILURE) { return; } @@ -2776,7 +2770,7 @@ PHP_FUNCTION(mb_substr) string.no_language = MBSTRG(language); string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding; - if (argc == 4) { + if (encoding) { string.no_encoding = mbfl_name2no_encoding(encoding); if (string.no_encoding == mbfl_no_encoding_invalid) { php_error_docref(NULL, E_WARNING, "Unknown encoding \"%s\"", encoding); @@ -2787,11 +2781,8 @@ PHP_FUNCTION(mb_substr) string.val = (unsigned char *)str; string.len = str_len; - if (argc < 3 || Z_TYPE_P(z_len) == IS_NULL) { + if (len_is_null) { len = str_len; - } else { - convert_to_long_ex(z_len); - len = Z_LVAL_P(z_len); } /* measures length */ @@ -2840,22 +2831,21 @@ PHP_FUNCTION(mb_substr) Returns part of a string */ PHP_FUNCTION(mb_strcut) { - size_t argc = ZEND_NUM_ARGS(); - char *encoding; + char *encoding = NULL; zend_long from, len; size_t encoding_len; - zval *z_len = NULL; + zend_bool len_is_null = 1; mbfl_string string, result, *ret; mbfl_string_init(&string); string.no_language = MBSTRG(language); string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|zs", (char **)&string.val, (int **)&string.len, &from, &z_len, &encoding, &encoding_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|l!s", (char **)&string.val, (int **)&string.len, &from, &len, &len_is_null, &encoding, &encoding_len) == FAILURE) { return; } - if (argc == 4) { + if (encoding) { string.no_encoding = mbfl_name2no_encoding(encoding); if (string.no_encoding == mbfl_no_encoding_invalid) { php_error_docref(NULL, E_WARNING, "Unknown encoding \"%s\"", encoding); @@ -2863,11 +2853,8 @@ PHP_FUNCTION(mb_strcut) } } - if (argc < 3 || Z_TYPE_P(z_len) == IS_NULL) { + if (len_is_null) { len = string.len; - } else { - convert_to_long_ex(z_len); - len = Z_LVAL_P(z_len); } /* if "from" position is negative, count start position from the end @@ -2944,7 +2931,7 @@ PHP_FUNCTION(mb_strwidth) Trim the string in terminal width */ PHP_FUNCTION(mb_strimwidth) { - char *str, *trimmarker, *encoding; + char *str, *trimmarker = NULL, *encoding = NULL; zend_long from, width; size_t str_len, trimmarker_len, encoding_len; mbfl_string string, result, marker, *ret; @@ -2962,7 +2949,7 @@ PHP_FUNCTION(mb_strimwidth) marker.val = NULL; marker.len = 0; - if (ZEND_NUM_ARGS() == 5) { + if (encoding) { string.no_encoding = marker.no_encoding = mbfl_name2no_encoding(encoding); if (string.no_encoding == mbfl_no_encoding_invalid) { php_error_docref(NULL, E_WARNING, "Unknown encoding \"%s\"", encoding); @@ -2983,7 +2970,7 @@ PHP_FUNCTION(mb_strimwidth) RETURN_FALSE; } - if (ZEND_NUM_ARGS() >= 4) { + if (trimmarker) { marker.val = (unsigned char *)trimmarker; marker.len = trimmarker_len; } @@ -3092,7 +3079,7 @@ PHP_FUNCTION(mb_convert_encoding) { char *arg_str, *arg_new; size_t str_len, new_len; - zval *arg_old; + zval *arg_old = NULL; size_t size, l, n; char *_from_encodings = NULL, *ret, *s_free = NULL; @@ -3103,7 +3090,7 @@ PHP_FUNCTION(mb_convert_encoding) return; } - if (ZEND_NUM_ARGS() == 3) { + if (arg_old) { switch (Z_TYPE_P(arg_old)) { case IS_ARRAY: target_hash = Z_ARRVAL_P(arg_old); @@ -3241,21 +3228,21 @@ PHP_FUNCTION(mb_detect_encoding) char *str; size_t str_len; zend_bool strict=0; - zval *encoding_list; + zval *encoding_list = NULL; mbfl_string string; const mbfl_encoding *ret; const mbfl_encoding **elist, **list; size_t size; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|zb", &str, &str_len, &encoding_list, &strict) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &str, &str_len, &encoding_list, &strict) == FAILURE) { return; } /* make encoding list */ list = NULL; size = 0; - if (ZEND_NUM_ARGS() >= 2 && !Z_ISNULL_P(encoding_list)) { + if (encoding_list) { switch (Z_TYPE_P(encoding_list)) { case IS_ARRAY: if (FAILURE == php_mb_parse_encoding_array(encoding_list, &list, &size, 0)) { @@ -3780,17 +3767,16 @@ detect_end: static void php_mb_numericentity_exec(INTERNAL_FUNCTION_PARAMETERS, int type) { - char *str, *encoding; + char *str, *encoding = NULL; size_t str_len, encoding_len; zval *zconvmap, *hash_entry; HashTable *target_hash; - int argc = ZEND_NUM_ARGS(); int i, *convmap, *mapelm, mapsize=0; zend_bool is_hex = 0; mbfl_string string, result, *ret; enum mbfl_no_encoding no_encoding; - if (zend_parse_parameters(argc, "sz|sb", &str, &str_len, &zconvmap, &encoding, &encoding_len, &is_hex) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sz|sb", &str, &str_len, &zconvmap, &encoding, &encoding_len, &is_hex) == FAILURE) { return; } @@ -3801,7 +3787,7 @@ php_mb_numericentity_exec(INTERNAL_FUNCTION_PARAMETERS, int type) string.len = str_len; /* encoding */ - if ((argc == 3 || argc == 4) && encoding_len > 0) { + if (encoding && encoding_len > 0) { no_encoding = mbfl_name2no_encoding(encoding); if (no_encoding == mbfl_no_encoding_invalid) { php_error_docref(NULL, E_WARNING, "Unknown encoding \"%s\"", encoding); @@ -3811,10 +3797,8 @@ php_mb_numericentity_exec(INTERNAL_FUNCTION_PARAMETERS, int type) } } - if (argc == 4) { - if (type == 0 && is_hex) { - type = 2; /* output in hex format */ - } + if (type == 0 && is_hex) { + type = 2; /* output in hex format */ } /* conversion map */ diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 35a986ac2a..d2787262ae 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -653,8 +653,7 @@ _php_mb_regex_init_options(const char *parg, int narg, OnigOptionType *option, O Returns the current encoding for regex as a string. */ PHP_FUNCTION(mb_regex_encoding) { - size_t argc = ZEND_NUM_ARGS(); - char *encoding; + char *encoding = NULL; size_t encoding_len; OnigEncoding mbctype; @@ -662,7 +661,7 @@ PHP_FUNCTION(mb_regex_encoding) return; } - if (argc == 0) { + if (!encoding) { const char *retval = _php_mb_regex_mbctype2name(MBREX(current_mbctype)); if (retval == NULL) { @@ -670,7 +669,7 @@ PHP_FUNCTION(mb_regex_encoding) } RETURN_STRING((char *)retval); - } else if (argc == 1) { + } else { mbctype = _php_mb_regex_name2mbctype(encoding); if (mbctype == ONIG_ENCODING_UNDEF) { @@ -687,7 +686,7 @@ PHP_FUNCTION(mb_regex_encoding) /* {{{ _php_mb_regex_ereg_exec */ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) { - zval *arg_pattern, *array; + zval *arg_pattern, *array = NULL; char *string; size_t string_len; php_mb_regex_t *re; @@ -696,8 +695,6 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) OnigOptionType options; char *str; - array = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "zs|z/", &arg_pattern, &string, &string_len, &array) == FAILURE) { RETURN_FALSE; } @@ -1180,26 +1177,25 @@ PHP_FUNCTION(mb_ereg_match) static void _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode) { - size_t argc = ZEND_NUM_ARGS(); - char *arg_pattern, *arg_options; + char *arg_pattern = NULL, *arg_options = NULL; size_t arg_pattern_len, arg_options_len; int n, i, err, pos, len, beg, end; OnigOptionType option; OnigUChar *str; OnigSyntaxType *syntax; - if (zend_parse_parameters(argc, "|ss", &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) { return; } option = MBREX(regex_default_options); - if (argc == 2) { + if (arg_options) { option = 0; _php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, NULL); } - if (argc > 0) { + if (arg_pattern) { /* create regex pattern buffer */ if ((MBREX(search_re) = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, option, MBREX(current_mbctype), MBREX(regex_default_syntax))) == NULL) { RETURN_FALSE; diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index c3f0cc6c54..cc3de4286f 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -323,9 +323,9 @@ static PHP_FUNCTION(phpdbg_break_next) /* {{{ proto void phpdbg_break_file(string file, integer line) */ static PHP_FUNCTION(phpdbg_break_file) { - char *file = NULL; - size_t flen = 0; - long line; + char *file; + size_t flen; + zend_long line; if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl", &file, &flen, &line) == FAILURE) { return; @@ -378,9 +378,9 @@ static PHP_FUNCTION(phpdbg_clear) /* {{{ proto void phpdbg_color(integer element, string color) */ static PHP_FUNCTION(phpdbg_color) { - long element = 0L; - char *color = NULL; - size_t color_len = 0; + zend_long element; + char *color; + size_t color_len; if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &element, &color, &color_len) == FAILURE) { return; |