mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-29 03:45:43 +00:00
Merge branch 'PHP-7.0'
This commit is contained in:
commit
68c395346a
11 files changed
+101
-107
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
+28
-44
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
|
||||
define('REPORT_LEVEL', 2); // 0 reports less false-positives. up to level 5.
|
||||
define('REPORT_LEVEL', 1); // 0 reports less false-positives. up to level 5.
|
||||
define('VERSION', '7.0'); // minimum is 7.0
|
||||
define('PHPDIR', realpath(dirname(__FILE__) . '/../..'));
|
||||
|
||||
@@ -36,7 +36,6 @@ $API_params = array(
|
||||
'a' => array('zval**'), // array
|
||||
'A' => array('zval**'), // array or object
|
||||
'b' => array('zend_bool*'), // boolean
|
||||
'C' => array('zend_class_entry**'), // class
|
||||
'd' => array('double*'), // double
|
||||
'f' => array('zend_fcall_info*', 'zend_fcall_info_cache*'), // function
|
||||
'h' => array('HashTable**'), // array as an HashTable*
|
||||
@@ -50,7 +49,7 @@ $API_params = array(
|
||||
'S' => array('zend_string**'), // string
|
||||
'z' => array('zval**'), // zval*
|
||||
'Z' => array('zval***') // zval**
|
||||
// 's', 'p' handled separately
|
||||
// 's', 'p', 'C' handled separately
|
||||
);
|
||||
|
||||
/** reports an error, according to its level */
|
||||
@@ -130,7 +129,7 @@ function get_vars($txt)
|
||||
|
||||
|
||||
/** run diagnostic checks against one var. */
|
||||
function check_param_allow_uninit($db, $idx, $exp, $optional)
|
||||
function check_param($db, $idx, $exp, $optional, $allow_uninit = false)
|
||||
{
|
||||
global $error_few_vars_given;
|
||||
|
||||
@@ -151,12 +150,7 @@ function check_param_allow_uninit($db, $idx, $exp, $optional)
|
||||
if (!$optional && $db[$idx][2]) {
|
||||
error("not optional var is initialized: {$db[$idx][0]} [".($idx+1).']', 2);
|
||||
}
|
||||
}
|
||||
|
||||
function check_param($db, $idx, $exp, $optional)
|
||||
{
|
||||
check_param_allow_uninit($db, $idx, $exp, $optional);
|
||||
if ($optional && !$db[$idx][2]) {
|
||||
if (!$allow_uninit && $optional && !$db[$idx][2]) {
|
||||
error("optional var not initialized: {$db[$idx][0]} [".($idx+1).']', 1);
|
||||
}
|
||||
}
|
||||
@@ -199,7 +193,15 @@ function check_function($name, $txt, $offset)
|
||||
{
|
||||
global $API_params;
|
||||
|
||||
if (preg_match_all('/zend_parse_parameters(?:_ex\s*\([^,]+,[^,]+|\s*\([^,]+),\s*"([^"]*)"\s*,\s*([^{;]*)/S', $txt, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
|
||||
$regex = '/
|
||||
(?: zend_parse_parameters(?:_throw)? \s*\([^,]+
|
||||
| zend_parse_(?:parameters_ex|method_parameters) \s*\([^,]+,[^,]+
|
||||
| zend_parse_method_parameters_ex \s*\([^,]+,[^,]+,[^,+]
|
||||
)
|
||||
,\s*"([^"]*)"\s*
|
||||
,\s*([^{;]*)
|
||||
/Sx';
|
||||
if (preg_match_all($regex, $txt, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
|
||||
|
||||
$GLOBALS['current_function'] = $name;
|
||||
|
||||
@@ -210,12 +212,14 @@ function check_function($name, $txt, $offset)
|
||||
$vars = get_vars(substr($txt, 0, $m[0][1])); // limit var search to current location
|
||||
$params = get_params($vars, $m[2][0]);
|
||||
$optional = $varargs = false;
|
||||
$last_last_char = $last_char = '';
|
||||
$last_char = '';
|
||||
$j = -1;
|
||||
$len = strlen($m[1][0]);
|
||||
|
||||
$spec = $m[1][0];
|
||||
$len = strlen($spec);
|
||||
for ($i = 0; $i < $len; ++$i) {
|
||||
switch($char = $m[1][0][$i]) {
|
||||
$char = $spec[$i];
|
||||
switch ($char = $spec[$i]) {
|
||||
// separator for optional parameters
|
||||
case '|':
|
||||
if ($optional) {
|
||||
@@ -256,24 +260,34 @@ function check_function($name, $txt, $offset)
|
||||
|
||||
case 's':
|
||||
case 'p':
|
||||
check_param_allow_uninit($params, ++$j, 'char**', $optional);
|
||||
check_param_allow_uninit($params, ++$j, 'size_t*', $optional);
|
||||
if ($optional && !$params[$j-1][2] && !$params[$j][2]) {
|
||||
check_param($params, ++$j, 'char**', $optional, $allow_uninit=true);
|
||||
check_param($params, ++$j, 'size_t*', $optional, $allow_uninit=true);
|
||||
if ($optional && !$params[$j-1][2] && !$params[$j][2]
|
||||
&& $params[$j-1][0] !== '**dummy**' && $params[$j][0] !== '**dummy**') {
|
||||
error("one of optional vars {$params[$j-1][0]} or {$params[$j][0]} must be initialized", 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
// C must always be initialized, independently of whether it's optional
|
||||
check_param($params, ++$j, 'zend_class_entry**', false);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (isset($API_params[$char])) {
|
||||
foreach($API_params[$char] as $exp) {
|
||||
check_param($params, ++$j, $exp, $optional);
|
||||
}
|
||||
} else {
|
||||
if (!isset($API_params[$char])) {
|
||||
error("unknown char ('$char') at column $i");
|
||||
}
|
||||
|
||||
// If an is_null flag is in use, only that flag is required to be
|
||||
// initialized
|
||||
$allow_uninit = $i+1 < $len && $spec[$i+1] === '!'
|
||||
&& in_array($char, array('l', 'L', 'd', 'b'));
|
||||
|
||||
foreach ($API_params[$char] as $exp) {
|
||||
check_param($params, ++$j, $exp, $optional, $allow_uninit);
|
||||
}
|
||||
}
|
||||
|
||||
$last_last_char = $last_char;
|
||||
$last_char = $char;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user