diff options
| author | Anatol Belski <ab@php.net> | 2014-08-16 12:55:13 +0200 |
|---|---|---|
| committer | Anatol Belski <ab@php.net> | 2014-08-16 12:55:13 +0200 |
| commit | b7e7a895414bd1821686932d57949f1ad0693900 (patch) | |
| tree | d107d07e93948ccf115a73c27d6044d22ec64968 | |
| parent | cb25136f4ef1042295650475b2c20ace81e2b9b7 (diff) | |
| download | php-git-b7e7a895414bd1821686932d57949f1ad0693900.tar.gz | |
several fixes -
- param parsing Z_PARAM_STR vs Z_PARAM_STRING
- some functions for new params
- etc
| -rw-r--r-- | Zend/zend_API.c | 1 | ||||
| -rw-r--r-- | Zend/zend_API.h | 2 | ||||
| -rw-r--r-- | ext/pcre/php_pcre.c | 20 | ||||
| -rw-r--r-- | ext/standard/array.c | 80 | ||||
| -rw-r--r-- | ext/standard/base64.c | 6 | ||||
| -rw-r--r-- | ext/standard/base64.h | 6 | ||||
| -rw-r--r-- | ext/standard/basic_functions.c | 12 | ||||
| -rw-r--r-- | ext/standard/basic_functions.h | 8 | ||||
| -rw-r--r-- | ext/standard/dir.c | 2 | ||||
| -rw-r--r-- | ext/standard/file.c | 95 | ||||
| -rw-r--r-- | ext/standard/file.h | 10 | ||||
| -rw-r--r-- | ext/standard/filestat.c | 28 | ||||
| -rw-r--r-- | ext/standard/formatted_print.c | 80 | ||||
| -rw-r--r-- | ext/standard/link_win32.c | 2 | ||||
| -rw-r--r-- | ext/standard/math.c | 40 | ||||
| -rw-r--r-- | ext/standard/pageinfo.c | 2 | ||||
| -rw-r--r-- | ext/standard/php_math.h | 2 | ||||
| -rw-r--r-- | ext/standard/php_smart_str.h | 14 | ||||
| -rw-r--r-- | ext/standard/php_string.h | 12 | ||||
| -rw-r--r-- | ext/standard/scanf.c | 18 | ||||
| -rw-r--r-- | ext/standard/string.c | 150 | ||||
| -rw-r--r-- | ext/standard/var.c | 20 | ||||
| -rw-r--r-- | ext/standard/var_unserializer.re | 16 |
23 files changed, 306 insertions, 320 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index e94d49eabc..7ad1361210 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -932,6 +932,7 @@ static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va, case 'f': case 'A': case 'H': case 'p': case 'S': case 'P': + case 'i': max_num_args++; break; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 4478e60562..fa4ca96a42 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -1172,7 +1172,7 @@ static zend_always_inline int _z_param_str(zval *arg, zend_string **dest, int ch return 1; } -static zend_always_inline int _z_param_string(zval *arg, char **dest, zend_size_t *dest_len, int check_null TSRMLS_DC) +static zend_always_inline int _z_param_string(zval *arg, char **dest, int *dest_len, int check_null TSRMLS_DC) { zend_string *str; diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index ddfccc3763..bc878d0c31 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -541,22 +541,21 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ * { /* parameters */ zend_string *regex; /* Regular expression */ - char *subject; /* String to match against */ - int subject_len; + zend_string *subject; /* String to match against */ pcre_cache_entry *pce; /* Compiled regular expression */ zval *subpats = NULL; /* Array for subpatterns */ long flags = 0; /* Match control flags */ long start_offset = 0; /* Where the new search starts */ #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ss|z/ll", ®ex, - &subject, &subject_len, &subpats, &flags, &start_offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|z/ll", ®ex, + &subject, &subpats, &flags, &start_offset) == FAILURE) { RETURN_FALSE; } #else ZEND_PARSE_PARAMETERS_START(2, 5) Z_PARAM_STR(regex) - Z_PARAM_STRING(subject, subject_len) + Z_PARAM_STR(subject) Z_PARAM_OPTIONAL Z_PARAM_ZVAL_EX(subpats, 0, 1) Z_PARAM_LONG(flags) @@ -569,7 +568,7 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ * RETURN_FALSE; } - php_pcre_match_impl(pce, subject, subject_len, return_value, subpats, + php_pcre_match_impl(pce, subject->val, subject->len, return_value, subpats, global, ZEND_NUM_ARGS() >= 4, flags, start_offset TSRMLS_CC); } /* }}} */ @@ -1554,22 +1553,21 @@ static PHP_FUNCTION(preg_filter) static PHP_FUNCTION(preg_split) { zend_string *regex; /* Regular expression */ - char *subject; /* String to match against */ - int subject_len; + zend_string *subject; /* String to match against */ long limit_val = -1;/* Integer value of limit */ long flags = 0; /* Match control flags */ pcre_cache_entry *pce; /* Compiled regular expression */ /* Get function parameters and do error checking */ #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ss|ll", ®ex, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|ll", ®ex, &subject, &subject_len, &limit_val, &flags) == FAILURE) { RETURN_FALSE; } #else ZEND_PARSE_PARAMETERS_START(2, 4) Z_PARAM_STR(regex) - Z_PARAM_STRING(subject, subject_len) + Z_PARAM_STR(subject) Z_PARAM_OPTIONAL Z_PARAM_LONG(limit_val) Z_PARAM_LONG(flags) @@ -1581,7 +1579,7 @@ static PHP_FUNCTION(preg_split) RETURN_FALSE; } - php_pcre_split_impl(pce, subject, subject_len, return_value, limit_val, flags TSRMLS_CC); + php_pcre_split_impl(pce, subject->val, subject->len, return_value, limit_val, flags TSRMLS_CC); } /* }}} */ diff --git a/ext/standard/array.c b/ext/standard/array.c index 1675562a50..881809a151 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -255,7 +255,7 @@ PHP_FUNCTION(ksort) PHPAPI int php_count_recursive(zval *array, long mode TSRMLS_DC) /* {{{ */ { - long cnt = 0; + php_int_t cnt = 0; zval *element; if (Z_TYPE_P(array) == IS_ARRAY) { @@ -289,7 +289,7 @@ PHP_FUNCTION(count) { zval *array; long mode = COUNT_NORMAL; - long cnt; + php_int_t cnt; zval *element; #ifndef FAST_ZPP @@ -1230,7 +1230,7 @@ static void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior) /* {{{ *array, /* array to check in */ *entry, /* pointer to array entry */ res; /* comparison result */ - ulong num_idx; + php_uint_t num_idx; zend_string *str_idx; zend_bool strict = 0; /* strict comparison or not */ @@ -1360,7 +1360,7 @@ PHP_FUNCTION(extract) long extract_type = EXTR_OVERWRITE; zval *entry; zend_string *var_name; - ulong num_key; + php_uint_t num_key; int var_exists, count = 0; int extract_refs = 0; zend_array *symbol_table; @@ -1554,9 +1554,9 @@ PHP_FUNCTION(compact) PHP_FUNCTION(array_fill) { zval *val; - long start_key, num; + php_int_t start_key, num; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llz", &start_key, &num, &val) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iiz", &start_key, &num, &val) == FAILURE) { return; } @@ -1652,7 +1652,7 @@ PHP_FUNCTION(range) if (Z_TYPE_P(zlow) == IS_STRING && Z_TYPE_P(zhigh) == IS_STRING && Z_STRSIZE_P(zlow) >= 1 && Z_STRSIZE_P(zhigh) >= 1) { int type1, type2; unsigned char low, high; - long lstep = (long) step; + php_int_t lstep = (php_int_t) step; type1 = is_numeric_string(Z_STRVAL_P(zlow), Z_STRSIZE_P(zlow), NULL, NULL, 0); type2 = is_numeric_string(Z_STRVAL_P(zhigh), Z_STRSIZE_P(zhigh), NULL, NULL, 0); @@ -1709,7 +1709,7 @@ PHP_FUNCTION(range) } else if (Z_TYPE_P(zlow) == IS_DOUBLE || Z_TYPE_P(zhigh) == IS_DOUBLE || is_step_double) { double low, high, value; - long i; + php_int_t i; double_str: low = zval_get_double(zlow); high = zval_get_double(zhigh); @@ -1742,11 +1742,11 @@ double_str: } } else { double low, high; - long lstep; + php_int_t lstep; long_str: low = zval_get_double(zlow); high = zval_get_double(zhigh); - lstep = (long) step; + lstep = (php_int_t) step; Z_TYPE_INFO(tmp) = IS_INT; if (low > high) { /* Negative steps */ @@ -1755,7 +1755,7 @@ long_str: goto err; } for (; low >= high; low -= lstep) { - Z_IVAL(tmp) = (long)low; + Z_IVAL(tmp) = (php_int_t)low; zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp); } } else if (high > low) { /* Positive steps */ @@ -1764,11 +1764,11 @@ long_str: goto err; } for (; low <= high; low += lstep) { - Z_IVAL(tmp) = (long)low; + Z_IVAL(tmp) = (php_int_t)low; zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp); } } else { - Z_IVAL(tmp) = (long)low; + Z_IVAL(tmp) = (php_int_t)low; zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp); } } @@ -1995,7 +1995,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end) zval *stack, /* Input stack */ *val; /* Value to be popped */ zend_string *key = NULL; - ulong index; + php_uint_t index; #ifndef FAST_ZPP if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &stack) == FAILURE) { @@ -2145,13 +2145,13 @@ PHP_FUNCTION(array_splice) HashTable old_hash; uint idx; Bucket *p; /* Bucket used for traversing hash */ - long i, + php_int_t i, offset, length = 0, repl_num = 0; /* Number of replacement elements */ int num_in; /* Number of elements in the input array */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/l|lz/", &array, &offset, &length, &repl_array) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/i|iz/", &array, &offset, &length, &repl_array) == FAILURE) { return; } @@ -2190,7 +2190,7 @@ PHP_FUNCTION(array_splice) /* ..and the length */ if (length < 0) { size = num_in - offset + length; - } else if (((unsigned long) offset + (unsigned long) length) > (unsigned) num_in) { + } else if (((php_uint_t) offset + (php_uint_t) length) > (unsigned) num_in) { size = num_in - offset; } @@ -2222,16 +2222,16 @@ PHP_FUNCTION(array_slice) zval *input, /* Input array */ *z_length = NULL, /* How many elements to get */ *entry; /* An array entry */ - long offset, /* Offset to get elements from */ + php_int_t offset, /* Offset to get elements from */ length = 0; zend_bool preserve_keys = 0; /* Whether to preserve keys while copying to the new array or not */ int num_in, /* Number of elements in the input array */ pos; /* Current position in the array */ zend_string *string_key; - ulong num_key; + php_uint_t num_key; #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|zb", &input, &offset, &z_length, &preserve_keys) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ai|zb", &input, &offset, &z_length, &preserve_keys) == FAILURE) { return; } #else @@ -2265,7 +2265,7 @@ PHP_FUNCTION(array_slice) /* ..and the length */ if (length < 0) { length = num_in - offset + length; - } else if (((unsigned long) offset + (unsigned long) length) > (unsigned) num_in) { + } else if (((php_uint_t) offset + (php_uint_t) length) > (unsigned) num_in) { length = num_in - offset; } @@ -2404,7 +2404,7 @@ PHPAPI int php_array_replace_recursive(HashTable *dest, HashTable *src TSRMLS_DC { zval *src_entry, *dest_entry, *src_zval, *dest_zval; zend_string *string_key; - ulong num_key; + php_uint_t num_key; int ret; ZEND_HASH_FOREACH_KEY_VAL(src, num_key, string_key, src_entry) { @@ -2564,7 +2564,7 @@ PHP_FUNCTION(array_keys) new_val; /* New value */ int add_key; /* Flag to indicate whether a key should be added */ zend_bool strict = 0; /* do strict comparison */ - ulong num_idx; + php_uint_t num_idx; zend_string *str_idx; int (*is_equal_func)(zval *, zval *, zval * TSRMLS_DC) = is_equal_function; @@ -2775,7 +2775,7 @@ PHP_FUNCTION(array_reverse) zval *input, /* Input array */ *entry; /* An entry in the input array */ zend_string *string_key; - ulong num_key; + php_uint_t num_key; zend_bool preserve_keys = 0; /* whether to preserve keys */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|b", &input, &preserve_keys) == FAILURE) { @@ -2810,20 +2810,20 @@ PHP_FUNCTION(array_pad) zval *pads; /* Array to pass to splice */ HashTable *new_hash;/* Return value from splice */ HashTable old_hash; - long pad_size; /* Size to pad to */ - long pad_size_abs; /* Absolute value of pad_size */ + php_int_t pad_size; /* Size to pad to */ + php_int_t pad_size_abs; /* Absolute value of pad_size */ int input_size; /* Size of the input array */ int num_pads; /* How many pads do we need */ int do_pad; /* Whether we should do padding at all */ int i; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "alz", &input, &pad_size, &pad_value) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "aiz", &input, &pad_size, &pad_value) == FAILURE) { return; } /* Do some initial calculations */ input_size = zend_hash_num_elements(Z_ARRVAL_P(input)); - pad_size_abs = abs(pad_size); + pad_size_abs = ZEND_ABS(pad_size); if (pad_size_abs < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "You may only pad up to 1048576 elements at a time"); zval_dtor(return_value); @@ -2874,7 +2874,7 @@ PHP_FUNCTION(array_pad) PHP_FUNCTION(array_flip) { zval *array, *entry, data; - ulong num_idx; + php_uint_t num_idx; zend_string *str_idx; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) { @@ -2912,10 +2912,10 @@ PHP_FUNCTION(array_change_key_case) zval *array, *entry; zend_string *string_key; zend_string *new_key; - ulong num_key; - long change_to_upper=0; + php_uint_t num_key; + php_int_t change_to_upper=0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &change_to_upper) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|i", &array, &change_to_upper) == FAILURE) { return; } @@ -4141,12 +4141,12 @@ PHP_FUNCTION(array_multisort) PHP_FUNCTION(array_rand) { zval *input; - long randval, num_req = 1; + php_int_t randval, num_req = 1; int num_avail; zend_string *string_key; - ulong num_key; + php_uint_t num_key; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &input, &num_req) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|i", &input, &num_req) == FAILURE) { return; } @@ -4247,7 +4247,7 @@ PHP_FUNCTION(array_product) if (Z_TYPE(entry_n) == IS_INT && Z_TYPE_P(return_value) == IS_INT) { dval = (double)Z_IVAL_P(return_value) * (double)Z_IVAL(entry_n); - if ( (double)LONG_MIN <= dval && dval <= (double)LONG_MAX ) { + if ( (double)PHP_INT_MIN <= dval && dval <= (double)PHP_INT_MAX ) { Z_IVAL_P(return_value) *= Z_IVAL(entry_n); continue; } @@ -4328,7 +4328,7 @@ PHP_FUNCTION(array_filter) zend_string *string_key; zend_fcall_info fci = empty_fcall_info; zend_fcall_info_cache fci_cache = empty_fcall_info_cache; - ulong num_key; + php_uint_t num_key; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|fl", &array, &fci, &fci_cache, &use_type) == FAILURE) { return; @@ -4620,15 +4620,15 @@ PHP_FUNCTION(array_key_exists) PHP_FUNCTION(array_chunk) { int argc = ZEND_NUM_ARGS(), num_in; - long size, current = 0; + php_int_t size, current = 0; zend_string *str_key; - ulong num_key; + php_uint_t num_key; zend_bool preserve_keys = 0; zval *input = NULL; zval chunk; zval *entry; - if (zend_parse_parameters(argc TSRMLS_CC, "al|b", &input, &size, &preserve_keys) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "ai|b", &input, &size, &preserve_keys) == FAILURE) { return; } /* Do bounds checking for size parameter. */ diff --git a/ext/standard/base64.c b/ext/standard/base64.c index 3bc96267b2..7ee643a7d5 100644 --- a/ext/standard/base64.c +++ b/ext/standard/base64.c @@ -53,7 +53,7 @@ static const short base64_reverse_table[256] = { }; /* }}} */ -PHPAPI zend_string *php_base64_encode(const unsigned char *str, int length) /* {{{ */ +PHPAPI zend_string *php_base64_encode(const unsigned char *str, php_size_t length) /* {{{ */ { const unsigned char *current = str; unsigned char *p; @@ -131,13 +131,13 @@ void php_base64_init(void) */ /* }}} */ -PHPAPI zend_string *php_base64_decode(const unsigned char *str, int length) /* {{{ */ +PHPAPI zend_string *php_base64_decode(const unsigned char *str, php_size_t length) /* {{{ */ { return php_base64_decode_ex(str, length, 0); } /* }}} */ -PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, int length, zend_bool strict) /* {{{ */ +PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, php_size_t length, zend_bool strict) /* {{{ */ { const unsigned char *current = str; int ch, i = 0, j = 0, k; diff --git a/ext/standard/base64.h b/ext/standard/base64.h index e58565702a..dd07db56e1 100644 --- a/ext/standard/base64.h +++ b/ext/standard/base64.h @@ -24,9 +24,9 @@ PHP_FUNCTION(base64_decode); PHP_FUNCTION(base64_encode); -PHPAPI extern zend_string *php_base64_encode(const unsigned char *, int); -PHPAPI extern zend_string *php_base64_decode_ex(const unsigned char *, int, zend_bool); -PHPAPI extern zend_string *php_base64_decode(const unsigned char *, int); +PHPAPI extern zend_string *php_base64_encode(const unsigned char *, php_size_t); +PHPAPI extern zend_string *php_base64_decode_ex(const unsigned char *, php_size_t, zend_bool); +PHPAPI extern zend_string *php_base64_decode(const unsigned char *, php_size_t); #endif /* BASE64_H */ diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index f2f358b3f3..605d9ddc7d 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -4386,9 +4386,9 @@ PHP_FUNCTION(flush) Delay for a given number of seconds */ PHP_FUNCTION(sleep) { - long num; + php_int_t num; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &num) == FAILURE) { RETURN_FALSE; } if (num < 0) { @@ -4409,9 +4409,9 @@ PHP_FUNCTION(sleep) PHP_FUNCTION(usleep) { #if HAVE_USLEEP - long num; + php_int_t num; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &num) == FAILURE) { return; } if (num < 0) { @@ -4428,7 +4428,7 @@ PHP_FUNCTION(usleep) Delay for a number of seconds and nano seconds */ PHP_FUNCTION(time_nanosleep) { - long tv_sec, tv_nsec; + php_int_t tv_sec, tv_nsec; struct timespec php_req, php_rem; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &tv_sec, &tv_nsec) == FAILURE) { @@ -5778,7 +5778,7 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal } if (!(Z_STRSIZE_P(arg1) > 1 && Z_STRVAL_P(arg1)[0] == '0') && is_numeric_string(Z_STRVAL_P(arg1), Z_STRSIZE_P(arg1), NULL, NULL, 0) == IS_INT) { - ulong key = (ulong) zend_atol(Z_STRVAL_P(arg1), Z_STRSIZE_P(arg1)); + php_uint_t key = (php_uint_t) zend_atol(Z_STRVAL_P(arg1), Z_STRSIZE_P(arg1)); if ((find_hash = zend_hash_index_find(Z_ARRVAL_P(arr), key)) == NULL) { array_init(&hash); find_hash = zend_hash_index_update(Z_ARRVAL_P(arr), key, &hash); diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index 3cabf87d1a..ee79269cae 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -167,7 +167,7 @@ typedef struct _php_basic_globals { char *locale_string; char *strtok_last; char strtok_table[256]; - ulong strtok_len; + php_uint_t strtok_len; char str_ebuf[40]; zend_fcall_info array_walk_fci; zend_fcall_info_cache array_walk_fci_cache; @@ -178,9 +178,9 @@ typedef struct _php_basic_globals { zval active_ini_file_section; /* pageinfo.c */ - long page_uid; - long page_gid; - long page_inode; + php_int_t page_uid; + php_int_t page_gid; + php_int_t page_inode; time_t page_mtime; /* filestat.c && main/streams/streams.c */ diff --git a/ext/standard/dir.c b/ext/standard/dir.c index e721de9774..3e65f72699 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -524,7 +524,7 @@ no_results: * able to filter directories out. */ if (flags & GLOB_ONLYDIR) { - struct stat s; + php_stat_t s; if (0 != VCWD_STAT(globbuf.gl_pathv[n], &s)) { continue; diff --git a/ext/standard/file.c b/ext/standard/file.c index 5b0237ba4e..c6a80df005 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -342,9 +342,9 @@ PHP_FUNCTION(flock) zval *arg1, *arg3 = NULL; int act; php_stream *stream; - long operation = 0; + php_int_t operation = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z/", &arg1, &operation, &arg3) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri|z/", &arg1, &operation, &arg3) == FAILURE) { return; } @@ -526,14 +526,14 @@ PHP_FUNCTION(file_get_contents) int filename_len; zend_bool use_include_path = 0; php_stream *stream; - long offset = -1; - long maxlen = PHP_STREAM_COPY_ALL; + php_int_t offset = -1; + php_int_t maxlen = PHP_STREAM_COPY_ALL; zval *zcontext = NULL; php_stream_context *context = NULL; zend_string *contents; /* Parse arguments */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|br!ll", &filename, &filename_len, &use_include_path, &zcontext, &offset, &maxlen) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|br!ii", &filename, &filename_len, &use_include_path, &zcontext, &offset, &maxlen) == FAILURE) { return; } @@ -552,7 +552,7 @@ PHP_FUNCTION(file_get_contents) } if (offset > 0 && php_stream_seek(stream, offset, SEEK_SET) < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", offset); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position " ZEND_INT_FMT " in the stream", offset); php_stream_close(stream); RETURN_FALSE; } @@ -579,14 +579,15 @@ PHP_FUNCTION(file_put_contents) char *filename; int filename_len; zval *data; - long numbytes = 0; - long flags = 0; + php_int_t numbytes = 0; + php_int_t flags = 0; zval *zcontext = NULL; php_stream_context *context = NULL; php_stream *srcstream = NULL; char mode[3] = "wb"; + char ret_ok = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pz/|lr!", &filename, &filename_len, &data, &flags, &zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pz/|ir!", &filename, &filename_len, &data, &flags, &zcontext) == FAILURE) { return; } @@ -627,13 +628,13 @@ PHP_FUNCTION(file_put_contents) switch (Z_TYPE_P(data)) { case IS_RESOURCE: { - size_t len; + php_size_t len; if (php_stream_copy_to_stream_ex(srcstream, stream, PHP_STREAM_COPY_ALL, &len) != SUCCESS) { - numbytes = -1; + ret_ok = 0; } else { - if (len > LONG_MAX) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "content truncated from %lu to %ld bytes", (unsigned long) len, LONG_MAX); - len = LONG_MAX; + if (len > PHP_INT_MAX) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "content truncated from %zu to " ZEND_INT_FMT " bytes", len, PHP_INT_MAX); + len = PHP_INT_MAX; } numbytes = len; } @@ -650,7 +651,7 @@ PHP_FUNCTION(file_put_contents) if (Z_STRSIZE_P(data)) { numbytes = php_stream_write(stream, Z_STRVAL_P(data), Z_STRSIZE_P(data)); if (numbytes != Z_STRSIZE_P(data)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %ld of %d bytes written, possibly out of free disk space", numbytes, Z_STRSIZE_P(data)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %ld of %zd bytes written, possibly out of free disk space", numbytes, Z_STRSIZE_P(data)); numbytes = -1; } } @@ -658,7 +659,7 @@ PHP_FUNCTION(file_put_contents) case IS_ARRAY: if (zend_hash_num_elements(Z_ARRVAL_P(data))) { - int bytes_written; + php_size_t bytes_written; zval *tmp; ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(data), tmp) { @@ -666,13 +667,9 @@ PHP_FUNCTION(file_put_contents) if (str->len) { numbytes += str->len; bytes_written = php_stream_write(stream, str->val, str->len); - if (bytes_written < 0 || bytes_written != str->len) { - if (bytes_written < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write %d bytes to %s", str->len, filename); - } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", bytes_written, str->len); - } - numbytes = -1; + if (bytes_written != str->len) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write %zd bytes to %s", str->len, filename); + ret_ok = 0; STR_RELEASE(str); break; } @@ -689,7 +686,7 @@ PHP_FUNCTION(file_put_contents) if (zend_std_cast_object_tostring(data, &out, IS_STRING TSRMLS_CC) == SUCCESS) { numbytes = php_stream_write(stream, Z_STRVAL(out), Z_STRSIZE(out)); if (numbytes != Z_STRSIZE(out)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %ld of %d bytes written, possibly out of free disk space", numbytes, Z_STRSIZE(out)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %ld of %zd bytes written, possibly out of free disk space", numbytes, Z_STRSIZE(out)); numbytes = -1; } zval_dtor(&out); @@ -697,12 +694,12 @@ PHP_FUNCTION(file_put_contents) } } default: - numbytes = -1; + ret_ok = 0; break; } php_stream_close(stream); - if (numbytes < 0) { + if (!ret_ok) { RETURN_FALSE; } @@ -721,7 +718,7 @@ PHP_FUNCTION(file) char *p, *s, *e; register int i = 0; char eol_marker = '\n'; - long flags = 0; + php_int_t flags = 0; zend_bool use_include_path; zend_bool include_new_line; zend_bool skip_blank_lines; @@ -731,11 +728,11 @@ PHP_FUNCTION(file) zend_string *target_buf; /* Parse arguments */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|lr!", &filename, &filename_len, &flags, &zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|ir!", &filename, &filename_len, &flags, &zcontext) == FAILURE) { return; } if (flags < 0 || flags > (PHP_FILE_USE_INCLUDE_PATH | PHP_FILE_IGNORE_NEW_LINES | PHP_FILE_SKIP_EMPTY_LINES | PHP_FILE_NO_DEFAULT_CONTEXT)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "'%ld' flag is not supported", flags); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "'" ZEND_INT_FMT "' flag is not supported", flags); RETURN_FALSE; } @@ -1010,13 +1007,13 @@ PHPAPI PHP_FUNCTION(feof) PHPAPI PHP_FUNCTION(fgets) { zval *arg1; - long len = 1024; + php_int_t len = 1024; char *buf = NULL; int argc = ZEND_NUM_ARGS(); size_t line_len = 0; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &arg1, &len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|i", &arg1, &len) == FAILURE) { RETURN_FALSE; } @@ -1094,7 +1091,7 @@ PHPAPI PHP_FUNCTION(fgetc) PHPAPI PHP_FUNCTION(fgetss) { zval *fd; - long bytes = 0; + php_int_t bytes = 0; size_t len = 0; size_t actual_len, retval_len; char *buf = NULL, *retval; @@ -1103,7 +1100,7 @@ PHPAPI PHP_FUNCTION(fgetss) char *allowed_tags=NULL; int allowed_tags_len=0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|lS", &fd, &bytes, &allowed) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|iS", &fd, &bytes, &allowed) == FAILURE) { RETURN_FALSE; } @@ -1200,11 +1197,11 @@ PHPAPI PHP_FUNCTION(fwrite) int arg2len; int ret; int num_bytes; - long arg3 = 0; + php_int_t arg3 = 0; char *buffer = NULL; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &arg1, &arg2, &arg2len, &arg3) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|i", &arg1, &arg2, &arg2len, &arg3) == FAILURE) { RETURN_FALSE; } @@ -1276,7 +1273,7 @@ PHPAPI PHP_FUNCTION(rewind) PHPAPI PHP_FUNCTION(ftell) { zval *arg1; - long ret; + php_int_t ret; php_stream *stream; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { @@ -1298,10 +1295,10 @@ PHPAPI PHP_FUNCTION(ftell) PHPAPI PHP_FUNCTION(fseek) { zval *arg1; - long arg2, whence = SEEK_SET; + php_int_t arg2, whence = SEEK_SET; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &arg1, &arg2, &whence) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri|i", &arg1, &arg2, &whence) == FAILURE) { RETURN_FALSE; } @@ -1315,7 +1312,7 @@ PHPAPI PHP_FUNCTION(fseek) */ /* DEPRECATED APIs: Use php_stream_mkdir() instead */ -PHPAPI int php_mkdir_ex(const char *dir, long mode, int options TSRMLS_DC) +PHPAPI int php_mkdir_ex(const char *dir, php_int_t mode, int options TSRMLS_DC) { int ret; @@ -1330,7 +1327,7 @@ PHPAPI int php_mkdir_ex(const char *dir, long mode, int options TSRMLS_DC) return ret; } -PHPAPI int php_mkdir(const char *dir, long mode TSRMLS_DC) +PHPAPI int php_mkdir(const char *dir, php_int_t mode TSRMLS_DC) { return php_mkdir_ex(dir, mode, REPORT_ERRORS TSRMLS_CC); } @@ -1409,7 +1406,7 @@ PHP_FUNCTION(readfile) Return or change the umask */ PHP_FUNCTION(umask) { - long arg1 = 0; + php_int_t arg1 = 0; int oldumask; oldumask = umask(077); @@ -1418,7 +1415,7 @@ PHP_FUNCTION(umask) BG(umask) = oldumask; } - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &arg1) == FAILURE) { RETURN_FALSE; } @@ -1524,10 +1521,10 @@ PHP_FUNCTION(unlink) PHP_NAMED_FUNCTION(php_if_ftruncate) { zval *fp; - long size; + php_int_t size; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &fp, &size) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri", &fp, &size) == FAILURE) { RETURN_FALSE; } @@ -1767,10 +1764,10 @@ safe_to_copy: PHPAPI PHP_FUNCTION(fread) { zval *arg1; - long len; + php_int_t len; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri", &arg1, &len) == FAILURE) { RETURN_FALSE; } @@ -1891,8 +1888,8 @@ PHP_FUNCTION(fputcsv) } /* }}} */ -/* {{{ PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC) */ -PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC) +/* {{{ PHPAPI php_size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC) */ +PHPAPI php_size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC) { int count, i = 0, ret; zval *field_tmp; @@ -1959,7 +1956,7 @@ PHP_FUNCTION(fgetcsv) /* first section exactly as php_fgetss */ - long len = 0; + php_int_t len = 0; size_t buf_len; char *buf; php_stream *stream; diff --git a/ext/standard/file.h b/ext/standard/file.h index 9c044aff1e..b667a29233 100644 --- a/ext/standard/file.h +++ b/ext/standard/file.h @@ -77,10 +77,10 @@ PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC); PHPAPI int php_copy_file(const char *src, const char *dest TSRMLS_DC); PHPAPI int php_copy_file_ex(const char *src, const char *dest, int src_chk TSRMLS_DC); PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_chk, php_stream_context *ctx TSRMLS_DC); -PHPAPI int php_mkdir_ex(const char *dir, long mode, int options TSRMLS_DC); -PHPAPI int php_mkdir(const char *dir, long mode TSRMLS_DC); +PHPAPI int php_mkdir_ex(const char *dir, php_int_t mode, int options TSRMLS_DC); +PHPAPI int php_mkdir(const char *dir, php_int_t mode TSRMLS_DC); PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char escape_char, size_t buf_len, char *buf, zval *return_value TSRMLS_DC); -PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC); +PHPAPI php_size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC); #define META_DEF_BUFSIZE 8192 @@ -117,8 +117,8 @@ php_meta_tags_token php_next_meta_token(php_meta_tags_data * TSRMLS_DC); typedef struct { int pclose_ret; size_t def_chunk_size; - long auto_detect_line_endings; - long default_socket_timeout; + php_int_t auto_detect_line_endings; + php_int_t default_socket_timeout; char *user_agent; /* for the http wrapper */ char *from_address; /* for the ftp and http wrappers */ const char *user_stream_current_filename; /* for simple recursion protection */ diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index b1b7e5933a..15af20198e 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -668,12 +668,12 @@ PHP_FUNCTION(chmod) { char *filename; int filename_len; - long mode; + php_int_t mode; int ret; mode_t imode; php_stream_wrapper *wrapper; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pl", &filename, &filename_len, &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pi", &filename, &filename_len, &mode) == FAILURE) { return; } @@ -714,14 +714,14 @@ PHP_FUNCTION(touch) { char *filename; int filename_len; - long filetime = 0, fileatime = 0; + php_int_t filetime = 0, fileatime = 0; int ret, argc = ZEND_NUM_ARGS(); FILE *file; struct utimbuf newtimebuf; struct utimbuf *newtime = &newtimebuf; php_stream_wrapper *wrapper; - if (zend_parse_parameters(argc TSRMLS_CC, "p|ll", &filename, &filename_len, &filetime, &fileatime) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "p|ii", &filename, &filename_len, &filetime, &fileatime) == FAILURE) { return; } @@ -850,7 +850,7 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ { zval stat_dev, stat_ino, stat_mode, stat_nlink, stat_uid, stat_gid, stat_rdev, stat_size, stat_atime, stat_mtime, stat_ctime, stat_blksize, stat_blocks; - struct stat *stat_sb; + zend_stat_t *stat_sb; php_stream_statbuf ssb; int flags = 0, rmask=S_IROTH, wmask=S_IWOTH, xmask=S_IXOTH; /* access rights defaults to other */ char *stat_sb_names[13] = { @@ -962,21 +962,21 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ switch (type) { case FS_PERMS: - RETURN_INT((long)ssb.sb.st_mode); + RETURN_INT((php_int_t)ssb.sb.st_mode); case FS_INODE: - RETURN_INT((long)ssb.sb.st_ino); + RETURN_INT((php_int_t)ssb.sb.st_ino); case FS_SIZE: - RETURN_INT((long)ssb.sb.st_size); + RETURN_INT((php_int_t)ssb.sb.st_size); case FS_OWNER: - RETURN_INT((long)ssb.sb.st_uid); + RETURN_INT((php_int_t)ssb.sb.st_uid); case FS_GROUP: - RETURN_INT((long)ssb.sb.st_gid); + RETURN_INT((php_int_t)ssb.sb.st_gid); case FS_ATIME: - RETURN_INT((long)ssb.sb.st_atime); + RETURN_INT((php_int_t)ssb.sb.st_atime); case FS_MTIME: - RETURN_INT((long)ssb.sb.st_mtime); + RETURN_INT((php_int_t)ssb.sb.st_mtime); case FS_CTIME: - RETURN_INT((long)ssb.sb.st_ctime); + RETURN_INT((php_int_t)ssb.sb.st_ctime); case FS_TYPE: if (S_ISLNK(ssb.sb.st_mode)) { RETURN_STRING("link"); @@ -1223,7 +1223,7 @@ PHP_FUNCTION(realpath_cache_get) array_init(&entry); /* bucket->key is unsigned long */ - if (LONG_MAX >= bucket->key) { + if (ZEND_INT_MAX >= bucket->key) { add_assoc_int(&entry, "key", bucket->key); } else { add_assoc_double(&entry, "key", (double)bucket->key); diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 4725f46386..4109da1718 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -52,7 +52,7 @@ static char HEXCHARS[] = "0123456789ABCDEF"; /* php_spintf_appendchar() {{{ */ inline static void -php_sprintf_appendchar(zend_string **buffer, int *pos, char add TSRMLS_DC) +php_sprintf_appendchar(zend_string **buffer, php_size_t *pos, char add TSRMLS_DC) { if (!*buffer || (*pos + 1) >= (*buffer)->len) { PRINTF_DEBUG(("%s(): ereallocing buffer to %d bytes\n", get_active_function_name(TSRMLS_C), (*buffer)->len)); @@ -65,22 +65,18 @@ php_sprintf_appendchar(zend_string **buffer, int *pos, char add TSRMLS_DC) /* php_spintf_appendstring() {{{ */ inline static void -php_sprintf_appendstring(zend_string **buffer, int *pos, char *add, - int min_width, int max_width, char padding, - int alignment, int len, int neg, int expprec, int always_sign) +php_sprintf_appendstring(zend_string **buffer, php_size_t *pos, char *add, + php_size_t min_width, php_size_t max_width, char padding, + php_size_t alignment, php_size_t len, int neg, int expprec, int always_sign) { - register int npad; - int req_size; - int copy_len; - int m_width; + register php_size_t npad; + php_size_t req_size; + php_size_t copy_len; + php_size_t m_width; copy_len = (expprec ? MIN(max_width, len) : len); - npad = min_width - copy_len; + npad = (min_width < copy_len) ? 0 : min_width - copy_len; - if (npad < 0) { - npad = 0; - } - PRINTF_DEBUG(("sprintf: appendstring(%x, %d, %d, \"%s\", %d, '%c', %d)\n", *buffer, *pos, (*buffer)->len, add, min_width, padding, alignment)); m_width = MAX(min_width, copy_len); @@ -92,10 +88,10 @@ php_sprintf_appendstring(zend_string **buffer, int *pos, char *add, req_size = *pos + m_width + 1; if (!*buffer || req_size > (*buffer)->len) { - int size = (*buffer)->len; + zend_size_t size = (*buffer)->len; while (req_size > size) { - if (size > INT_MAX/2) { - zend_error_noreturn(E_ERROR, "Field width %d is too long", req_size); + if (size > ZEND_SIZE_MAX/2) { + zend_error_noreturn(E_ERROR, "Field width %zd is too long", req_size); } size <<= 1; } @@ -126,21 +122,21 @@ php_sprintf_appendstring(zend_string **buffer, int *pos, char *add, /* php_spintf_appendint() {{{ */ inline static void -php_sprintf_appendint(zend_string **buffer, int *pos, long number, - int width, char padding, int alignment, +php_sprintf_appendint(zend_string **buffer, php_size_t *pos, php_int_t number, + php_size_t width, char padding, php_size_t alignment, int always_sign) { char numbuf[NUM_BUF_SIZE]; - register unsigned long magn, nmagn; + register php_uint_t magn, nmagn; register unsigned int i = NUM_BUF_SIZE - 1, neg = 0; PRINTF_DEBUG(("sprintf: appendint(%x, %x, %x, %d, %d, '%c', %d)\n", *buffer, pos, &(*buffer)->len, number, width, padding, alignment)); if (number < 0) { neg = 1; - magn = ((unsigned long) -(number + 1)) + 1; + magn = ((php_uint_t) -(number + 1)) + 1; } else { - magn = (unsigned long) number; + magn = (php_uint_t) number; } /* Can't right-pad 0's on integers */ @@ -170,17 +166,17 @@ php_sprintf_appendint(zend_string **buffer, int *pos, long number, /* php_spintf_appenduint() {{{ */ inline static void -php_sprintf_appenduint(zend_string **buffer, int *pos, - unsigned long number, - int width, char padding, int alignment) +php_sprintf_appenduint(zend_string **buffer, php_size_t *pos, + php_uint_t number, + php_size_t width, char padding, php_size_t alignment) { char numbuf[NUM_BUF_SIZE]; - register unsigned long magn, nmagn; + register php_uint_t magn, nmagn; register unsigned int i = NUM_BUF_SIZE - 1; PRINTF_DEBUG(("sprintf: appenduint(%x, %x, %x, %d, %d, '%c', %d)\n", *buffer, pos, &(*buffer)->len, number, width, padding, alignment)); - magn = (unsigned long) number; + magn = (php_uint_t) number; /* Can't right-pad 0's on integers */ if (alignment == 0 && padding == '0') padding = ' '; @@ -202,17 +198,18 @@ php_sprintf_appenduint(zend_string **buffer, int *pos, /* php_spintf_appenddouble() {{{ */ inline static void -php_sprintf_appenddouble(zend_string **buffer, int *pos, +php_sprintf_appenddouble(zend_string **buffer, php_size_t *pos, double number, - int width, char padding, - int alignment, int precision, + php_size_t width, char padding, + php_size_t alignment, int precision, int adjust, char fmt, int always_sign TSRMLS_DC) { char num_buf[NUM_BUF_SIZE]; char *s = NULL; - int s_len = 0, is_negative = 0; + php_size_t s_len = 0; + int is_negative = 0; #ifdef HAVE_LOCALE_H struct lconv *lconv; #endif @@ -293,13 +290,13 @@ php_sprintf_appenddouble(zend_string **buffer, int *pos, /* php_spintf_appendd2n() {{{ */ inline static void -php_sprintf_append2n(zend_string **buffer, int *pos, long number, - int width, char padding, int alignment, int n, +php_sprintf_append2n(zend_string **buffer, php_size_t *pos, php_int_t number, + php_size_t width, char padding, php_size_t alignment, int n, char *chartable, int expprec) { char numbuf[NUM_BUF_SIZE]; - register unsigned long num; - register unsigned int i = NUM_BUF_SIZE - 1; + register php_uint_t num; + register php_uint_t i = NUM_BUF_SIZE - 1; register int andbits = (1 << n) - 1; PRINTF_DEBUG(("sprintf: append2n(%x, %x, %x, %d, %d, '%c', %d, %d, %x)\n", @@ -307,7 +304,7 @@ php_sprintf_append2n(zend_string **buffer, int *pos, long number, chartable)); PRINTF_DEBUG(("sprintf: append2n 2^%d andbits=%x\n", n, andbits)); - num = (unsigned long) number; + num = (php_uint_t) number; numbuf[i] = '\0'; do { @@ -324,11 +321,11 @@ php_sprintf_append2n(zend_string **buffer, int *pos, long number, /* php_spintf_getnumber() {{{ */ inline static int -php_sprintf_getnumber(char *buffer, int *pos) +php_sprintf_getnumber(char *buffer, php_size_t *pos) { char *endptr; - register long num = strtol(&buffer[*pos], &endptr, 10); - register int i = 0; + register php_int_t num = ZEND_STRTOI(&buffer[*pos], &endptr, 10); + register php_size_t i = 0; if (endptr != NULL) { i = (endptr - &buffer[*pos]); @@ -373,7 +370,8 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC) { zval *newargs = NULL; zval *args, *z_format; - int argc, size = 240, inpos = 0, outpos = 0, temppos; + int argc; + php_size_t size = 240, inpos = 0, outpos = 0, temppos; int alignment, currarg, adjusting, argnum, width, precision; char *format, padding; zend_string *result; @@ -680,7 +678,7 @@ PHP_FUNCTION(vsprintf) PHP_FUNCTION(user_printf) { zend_string *result; - int rlen; + php_size_t rlen; if ((result=php_formatted_print(ZEND_NUM_ARGS(), 0, 0 TSRMLS_CC))==NULL) { RETURN_FALSE; @@ -696,7 +694,7 @@ PHP_FUNCTION(user_printf) PHP_FUNCTION(vprintf) { zend_string *result; - int rlen; + php_size_t rlen; if ((result=php_formatted_print(ZEND_NUM_ARGS(), 1, 0 TSRMLS_CC))==NULL) { RETURN_FALSE; diff --git a/ext/standard/link_win32.c b/ext/standard/link_win32.c index 60556c1fe2..8a04fb3f77 100644 --- a/ext/standard/link_win32.c +++ b/ext/standard/link_win32.c @@ -88,7 +88,7 @@ PHP_FUNCTION(linkinfo) { char *link; int link_len; - struct stat sb; + php_stat_t sb; int ret; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &link, &link_len) == FAILURE) { diff --git a/ext/standard/math.c b/ext/standard/math.c index a5387458f4..bf97f43770 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -286,8 +286,8 @@ PHP_FUNCTION(abs) if (Z_TYPE_P(value) == IS_DOUBLE) { RETURN_DOUBLE(fabs(Z_DVAL_P(value))); } else if (Z_TYPE_P(value) == IS_INT) { - if (Z_IVAL_P(value) == LONG_MIN) { - RETURN_DOUBLE(-(double)LONG_MIN); + if (Z_IVAL_P(value) == ZEND_INT_MIN) { + RETURN_DOUBLE(-(double)ZEND_INT_MIN); } else { RETURN_INT(Z_IVAL_P(value) < 0 ? -Z_IVAL_P(value) : Z_IVAL_P(value)); } @@ -342,11 +342,11 @@ PHP_FUNCTION(round) { zval *value; int places = 0; - long precision = 0; - long mode = PHP_ROUND_HALF_UP; + php_int_t precision = 0; + php_int_t mode = PHP_ROUND_HALF_UP; double return_val; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ll", &value, &precision, &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ii", &value, &precision, &mode) == FAILURE) { return; } @@ -926,9 +926,9 @@ PHP_FUNCTION(rad2deg) /* * Convert a string representation of a base(2-36) number to a long. */ -PHPAPI long _php_math_basetolong(zval *arg, int base) +PHPAPI php_int_t _php_math_basetolong(zval *arg, int base) { - long num = 0, digit, onum; + php_int_t num = 0, digit, onum; int i; char c, *s; @@ -959,7 +959,7 @@ PHPAPI long _php_math_basetolong(zval *arg, int base) TSRMLS_FETCH(); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number '%s' is too big to fit in long", s); - return LONG_MAX; + return ZEND_INT_MAX; } } @@ -973,12 +973,12 @@ PHPAPI long _php_math_basetolong(zval *arg, int base) */ PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret) { - long num = 0; + php_int_t num = 0; double fnum = 0; int i; int mode = 0; char c, *s; - long cutoff; + php_int_t cutoff; int cutlim; if (Z_TYPE_P(arg) != IS_STRING || base < 2 || base > 36) { @@ -987,8 +987,8 @@ PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret) s = Z_STRVAL_P(arg); - cutoff = LONG_MAX / base; - cutlim = LONG_MAX % base; + cutoff = ZEND_INT_MAX / base; + cutlim = ZEND_INT_MAX % base; for (i = Z_STRSIZE_P(arg); i > 0; i--) { c = *s++; @@ -1038,9 +1038,9 @@ PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret) PHPAPI zend_string * _php_math_longtobase(zval *arg, int base TSRMLS_DC) { static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; - char buf[(sizeof(unsigned long) << 3) + 1]; + char buf[(sizeof(php_uint_t) << 3) + 1]; char *ptr, *end; - unsigned long value; + php_uint_t value; if (Z_TYPE_P(arg) != IS_INT || base < 2 || base > 36) { return STR_EMPTY_ALLOC(); @@ -1200,20 +1200,20 @@ PHP_FUNCTION(dechex) PHP_FUNCTION(base_convert) { zval *number, temp; - long frombase, tobase; + php_int_t frombase, tobase; zend_string *result; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zll", &number, &frombase, &tobase) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zii", &number, &frombase, &tobase) == FAILURE) { return; } convert_to_string_ex(number); if (frombase < 2 || frombase > 36) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid `from base' (%ld)", frombase); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid `from base' (%pd)", frombase); RETURN_FALSE; } if (tobase < 2 || tobase > 36) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid `to base' (%ld)", tobase); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid `to base' (%pd)", tobase); RETURN_FALSE; } @@ -1350,13 +1350,13 @@ PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_poin PHP_FUNCTION(number_format) { double num; - long dec = 0; + php_int_t dec = 0; char *thousand_sep = NULL, *dec_point = NULL; char thousand_sep_chr = ',', dec_point_chr = '.'; int thousand_sep_len = 0, dec_point_len = 0; #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|ls!s!", &num, &dec, &dec_point, &dec_point_len, &thousand_sep, &thousand_sep_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|is!s!", &num, &dec, &dec_point, &dec_point_len, &thousand_sep, &thousand_sep_len) == FAILURE) { return; } #else diff --git a/ext/standard/pageinfo.c b/ext/standard/pageinfo.c index 9f7cab6edf..a92457e842 100644 --- a/ext/standard/pageinfo.c +++ b/ext/standard/pageinfo.c @@ -59,7 +59,7 @@ */ PHPAPI void php_statpage(TSRMLS_D) { - struct stat *pstat; + php_stat_t *pstat; pstat = sapi_get_stat(TSRMLS_C); diff --git a/ext/standard/php_math.h b/ext/standard/php_math.h index a2dca282c5..f8be7da42c 100644 --- a/ext/standard/php_math.h +++ b/ext/standard/php_math.h @@ -25,7 +25,7 @@ PHPAPI zend_string *_php_math_number_format(double, int, char, char); PHPAPI zend_string *_php_math_number_format_ex(double, int, char *, size_t, char *, size_t); PHPAPI zend_string * _php_math_longtobase(zval *arg, int base TSRMLS_DC); -PHPAPI long _php_math_basetolong(zval *arg, int base); +PHPAPI php_int_t _php_math_basetolong(zval *arg, int base); PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret); PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base TSRMLS_DC); diff --git a/ext/standard/php_smart_str.h b/ext/standard/php_smart_str.h index 2c8c966540..f4913f7b99 100644 --- a/ext/standard/php_smart_str.h +++ b/ext/standard/php_smart_str.h @@ -130,15 +130,15 @@ * #define f(..) ({char *r;..;__r;}) */ -static inline char *smart_str_print_long(char *buf, long num) { +static inline char *smart_str_print_long(char *buf, zend_int_t num) { char *r; - _zend_print_signed_to_buf(buf, num, long, r); + _zend_print_signed_to_buf(buf, num, zend_int_t, r); return r; } -static inline char *smart_str_print_unsigned(char *buf, long num) { +static inline char *smart_str_print_unsigned(char *buf, zend_int_t num) { char *r; - _zend_print_unsigned_to_buf(buf, num, unsigned long, r); + _zend_print_unsigned_to_buf(buf, num, zend_uint_t, r); return r; } @@ -150,13 +150,13 @@ static inline char *smart_str_print_unsigned(char *buf, long num) { } while (0) #define smart_str_append_unsigned_ex(dest, num, type) \ - smart_str_append_generic_ex((dest), (num), (type), unsigned long, _unsigned) + smart_str_append_generic_ex((dest), (num), (type), zend_uint_t, _unsigned) #define smart_str_append_int_ex(dest, num, type) \ - smart_str_append_generic_ex((dest), (num), (type), unsigned long, _signed) + smart_str_append_generic_ex((dest), (num), (type), zend_uint_t, _signed) #define smart_str_append_off_t_ex(dest, num, type) \ - smart_str_append_generic_ex((dest), (num), (type), off_t, _signed) + smart_str_append_generic_ex((dest), (num), (type), zend_off_t, _signed) #define smart_str_append_ex(dest, src, what) \ smart_str_appendl_ex((dest), ((smart_str *)(src))->s->val, \ diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h index 0f4240ea57..3618bdfe54 100644 --- a/ext/standard/php_string.h +++ b/ext/standard/php_string.h @@ -120,11 +120,11 @@ PHPAPI struct lconv *localeconv_r(struct lconv *out); PHPAPI char *php_strtoupper(char *s, size_t len); PHPAPI char *php_strtolower(char *s, size_t len); -PHPAPI char *php_strtr(char *str, int len, char *str_from, char *str_to, int trlen); -PHPAPI zend_string *php_addslashes(char *str, int length, int should_free TSRMLS_DC); -PHPAPI zend_string *php_addcslashes(const char *str, int length, int freeit, char *what, int wlength TSRMLS_DC); -PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC); -PHPAPI void php_stripcslashes(char *str, int *len); +PHPAPI char *php_strtr(char *str, php_size_t len, char *str_from, char *str_to, php_size_t trlen); +PHPAPI zend_string *php_addslashes(char *str, php_size_t length, int should_free TSRMLS_DC); +PHPAPI zend_string *php_addcslashes(const char *str, php_size_t length, int freeit, char *what, php_size_t wlength TSRMLS_DC); +PHPAPI void php_stripslashes(char *str, php_size_t *len TSRMLS_DC); +PHPAPI void php_stripcslashes(char *str, php_size_t *len); PHPAPI zend_string *php_basename(const char *s, size_t len, char *suffix, size_t sufflen TSRMLS_DC); PHPAPI size_t php_dirname(char *str, size_t len); PHPAPI char *php_stristr(char *s, char *t, size_t s_len, size_t t_len); @@ -132,7 +132,7 @@ PHPAPI zend_string *php_str_to_str_ex(char *haystack, int length, char *needle, int needle_len, char *str, int str_len, int case_sensitivity, int *replace_count); PHPAPI zend_string *php_str_to_str(char *haystack, int length, char *needle, int needle_len, char *str, int str_len); -PHPAPI char *php_trim(char *c, int len, char *what, int what_len, zval *return_value, int mode TSRMLS_DC); +PHPAPI char *php_trim(char *c, php_size_t len, char *what, php_size_t what_len, zval *return_value, int mode TSRMLS_DC); PHPAPI size_t php_strip_tags(char *rbuf, int len, int *state, char *allow, int allow_len); PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow, int allow_len, zend_bool allow_tag_spaces); PHPAPI int php_char_to_str_ex(char *str, uint len, char from, char *to, int to_len, zval *result, int case_sensitivity, int *replace_count); diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c index bf7d461b8b..626a52490b 100644 --- a/ext/standard/scanf.c +++ b/ext/standard/scanf.c @@ -582,7 +582,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format, { int numVars, nconversions, totalVars = -1; int i, result; - long value; + php_int_t value; int objIndex; char *end, *baseString; zval *current; @@ -590,7 +590,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format, int base = 0; int underflow = 0; size_t width; - long (*fn)() = NULL; + php_int_t (*fn)() = NULL; char *ch, sch; int flags; char buf[64]; /* Temporary buffer to hold scanned number @@ -744,7 +744,7 @@ literal: } else if (numVars) { current = Z_REFVAL(args[objIndex++]); zval_ptr_dtor(current); - ZVAL_INT(current, (long)(string - baseString) ); + ZVAL_INT(current, (php_int_t)(string - baseString) ); } else { add_index_int(return_value, objIndex++, string - baseString); } @@ -756,29 +756,29 @@ literal: case 'D': op = 'i'; base = 10; - fn = (long (*)())strtol; + fn = (php_int_t (*)())ZEND_STRTOI_PTR; break; case 'i': op = 'i'; base = 0; - fn = (long (*)())strtol; + fn = (php_int_t(*)())ZEND_STRTOI_PTR; break; case 'o': op = 'i'; base = 8; - fn = (long (*)())strtol; + fn = (php_int_t (*)())ZEND_STRTOI_PTR; break; case 'x': case 'X': op = 'i'; base = 16; - fn = (long (*)())strtol; + fn = (php_int_t (*)())ZEND_STRTOI_PTR; break; case 'u': op = 'i'; base = 10; flags |= SCAN_UNSIGNED; - fn = (long (*)())strtoul; + fn = (php_int_t (*)())ZEND_STRTOI_PTR; break; case 'f': @@ -1049,7 +1049,7 @@ addToInt: */ if (!(flags & SCAN_SUPPRESS)) { *end = '\0'; - value = (long) (*fn)(buf, NULL, base); + value = (php_int_t) (*fn)(buf, NULL, base); if ((flags & SCAN_UNSIGNED) && (value < 0)) { snprintf(buf, sizeof(buf), "%lu", value); /* INTL: ISO digit */ if (numVars && objIndex >= argCount) { diff --git a/ext/standard/string.c b/ext/standard/string.c index 7a9bca8adc..ee6e1df25e 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -284,7 +284,7 @@ static void php_spn_common_handler(INTERNAL_FUNCTION_PARAMETERS, int behavior) / { char *s11, *s22; int len1, len2; - long start = 0, len = 0; + php_int_t start = 0, len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ll", &s11, &len1, &s22, &len2, &start, &len) == FAILURE) { @@ -694,7 +694,7 @@ PHP_FUNCTION(nl_langinfo) #endif break; default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Item '%ld' is not valid", item); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Item '" ZEND_INT_FMT "' is not valid", item); RETURN_FALSE; } /* }}} */ @@ -732,7 +732,7 @@ PHP_FUNCTION(strcoll) * it needs to be incrementing. * Returns: FAILURE/SUCCESS whether the input was correct (i.e. no range errors) */ -static inline int php_charmask(unsigned char *input, int len, char *mask TSRMLS_DC) +static inline int php_charmask(unsigned char *input, php_size_t len, char *mask TSRMLS_DC) { unsigned char *end; unsigned char c; @@ -781,9 +781,9 @@ static inline int php_charmask(unsigned char *input, int len, char *mask TSRMLS_ * mode 3 : trim left and right * what indicates which chars are to be trimmed. NULL->default (' \t\n\r\v\0') */ -PHPAPI char *php_trim(char *c, int len, char *what, int what_len, zval *return_value, int mode TSRMLS_DC) +PHPAPI char *php_trim(char *c, php_size_t len, char *what, php_size_t what_len, zval *return_value, int mode TSRMLS_DC) { - register int i; + register php_int_t i; int trimmed = 0; char mask[256]; @@ -828,23 +828,22 @@ PHPAPI char *php_trim(char *c, int len, char *what, int what_len, zval *return_v */ static void php_do_trim(INTERNAL_FUNCTION_PARAMETERS, int mode) { - char *str; - char *what = NULL; - int str_len, what_len = 0; + zend_string *str; + zend_string *what = NULL; #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, &what, &what_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|S", &str, &what) == FAILURE) { return; } #else ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STRING(str, str_len) + Z_PARAM_STR(str) Z_PARAM_OPTIONAL - Z_PARAM_STRING(what, what_len) + Z_PARAM_STR(what) ZEND_PARSE_PARAMETERS_END(); #endif - php_trim(str, str_len, what, what_len, return_value, mode TSRMLS_CC); + php_trim(str->val, str->len, (what ? what->val : NULL), (what ? what->len : 0), return_value, mode TSRMLS_CC); } /* }}} */ @@ -1085,11 +1084,11 @@ PHPAPI void php_explode_negative_limit(zval *delim, zval *str, zval *return_valu PHP_FUNCTION(explode) { zend_string *str, *delim; - long limit = LONG_MAX; /* No limit */ + php_int_t limit = PHP_INT_MAX; /* No limit */ zval zdelim, zstr; #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|l", &delim, &str, &limit) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|i", &delim, &str, &limit) == FAILURE) { return; } #else @@ -1384,21 +1383,20 @@ PHPAPI char *php_strtolower(char *s, size_t len) Makes a string lowercase */ PHP_FUNCTION(strtolower) { - char *str; - int arglen; + zend_string *str; zend_string *result; #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &arglen) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) == FAILURE) { return; } #else ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STRING(str, arglen) + Z_PARAM_STR(str) ZEND_PARSE_PARAMETERS_END(); #endif - result = STR_INIT(str, arglen, 0); + result = STR_INIT(str->val, str->len, 0); php_strtolower(result->val, result->len); RETURN_NEW_STR(result); } @@ -2234,18 +2232,17 @@ PHP_FUNCTION(chunk_split) Returns part of a string */ PHP_FUNCTION(substr) { - char *str; - long l = 0, f; - int str_len; + zend_string *str; + php_int_t l = 0, f; int argc = ZEND_NUM_ARGS(); #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|l", &str, &str_len, &f, &l) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Si|i", &str, &f, &l) == FAILURE) { return; } #else ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STRING(str, str_len) + Z_PARAM_STR(str) Z_PARAM_LONG(f) Z_PARAM_OPTIONAL Z_PARAM_LONG(l) @@ -2253,22 +2250,22 @@ PHP_FUNCTION(substr) #endif if (argc > 2) { - if ((l < 0 && -l > str_len)) { + if ((l < 0 && -l > str->len)) { RETURN_FALSE; - } else if (l > str_len) { - l = str_len; + } else if (l > str->len) { + l = str->len; } } else { - l = str_len; + l = str->len; } - if (f > str_len) { + if (f > str->len) { RETURN_FALSE; - } else if (f < 0 && -f > str_len) { + } else if (f < 0 && -f > str->len) { f = 0; } - if (l < 0 && (l + str_len - f) < 0) { + if (l < 0 && (l + str->len - f) < 0) { RETURN_FALSE; } @@ -2276,7 +2273,7 @@ PHP_FUNCTION(substr) * of the string */ if (f < 0) { - f = str_len + f; + f = str->len + f; if (f < 0) { f = 0; } @@ -2286,21 +2283,21 @@ PHP_FUNCTION(substr) * needed to stop that many chars from the end of the string */ if (l < 0) { - l = (str_len - f) + l; + l = (str->len - f) + l; if (l < 0) { l = 0; } } - if (f >= str_len) { + if (f >= str->len) { RETURN_FALSE; } - if ((f + l) > str_len) { - l = str_len - f; + if ((f + l) > str->len) { + l = str->len - f; } - RETURN_STRINGL(str + f, l); + RETURN_STRINGL(str->val + f, l); } /* }}} */ @@ -2783,9 +2780,9 @@ PHP_FUNCTION(ucwords) /* {{{ php_strtr */ -PHPAPI char *php_strtr(char *str, int len, char *str_from, char *str_to, int trlen) +PHPAPI char *php_strtr(char *str, php_size_t len, char *str_from, char *str_to, php_size_t trlen) { - int i; + php_size_t i; unsigned char xlat[256]; if ((trlen < 1) || (len < 1)) { @@ -3127,10 +3124,10 @@ PHP_FUNCTION(similar_text) /* {{{ php_stripslashes * * be careful, this edits the string in-place */ -PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC) +PHPAPI void php_stripslashes(char *str, php_size_t *len TSRMLS_DC) { char *s, *t; - int l; + php_size_t l; if (len != NULL) { l = *len; @@ -3171,22 +3168,21 @@ PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC) Escapes all chars mentioned in charlist with backslash. It creates octal representations if asked to backslash characters with 8th bit set or with ASCII<32 (except '\n', '\r', '\t' etc...) */ PHP_FUNCTION(addcslashes) { - char *str, *what; - int str_len, what_len; + zend_string *str, *what; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &str, &str_len, &what, &what_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &str, &what) == FAILURE) { return; } - if (str_len == 0) { + if (str->len == 0) { RETURN_EMPTY_STRING(); } - if (what_len == 0) { - RETURN_STRINGL(str, str_len); + if (what->len == 0) { + RETURN_STRINGL(str->val, str->len); } - RETURN_STR(php_addcslashes(str, str_len, 0, what, what_len TSRMLS_CC)); + RETURN_STR(php_addcslashes(str->val, str->len, 0, what->val, what->len TSRMLS_CC)); } /* }}} */ @@ -3194,24 +3190,23 @@ PHP_FUNCTION(addcslashes) Escapes single quote, double quotes and backslash characters in a string with backslashes */ PHP_FUNCTION(addslashes) { - char *str; - int str_len; + zend_string *str; #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) == FAILURE) { return; } #else ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STRING(str, str_len) + Z_PARAM_STR(str) ZEND_PARSE_PARAMETERS_END(); #endif - if (str_len == 0) { + if (str->len == 0) { RETURN_EMPTY_STRING(); } - RETURN_STR(php_addslashes(str, str_len, 0 TSRMLS_CC)); + RETURN_STR(php_addslashes(str->val, str->len, 0 TSRMLS_CC)); } /* }}} */ @@ -3219,14 +3214,13 @@ PHP_FUNCTION(addslashes) Strips backslashes from a string. Uses C-style conventions */ PHP_FUNCTION(stripcslashes) { - char *str; - int str_len; + zend_string *str; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) == FAILURE) { return; } - ZVAL_STRINGL(return_value, str, str_len); + ZVAL_STRINGL(return_value, str->val, str->len); php_stripcslashes(Z_STRVAL_P(return_value), &Z_STRSIZE_P(return_value)); } /* }}} */ @@ -3235,14 +3229,13 @@ PHP_FUNCTION(stripcslashes) Strips backslashes from a string */ PHP_FUNCTION(stripslashes) { - char *str; - int str_len; + zend_string *str; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) == FAILURE) { return; } - ZVAL_STRINGL(return_value, str, str_len); + ZVAL_STRINGL(return_value, str->val, str->len); php_stripslashes(Z_STRVAL_P(return_value), &Z_STRSIZE_P(return_value) TSRMLS_CC); } /* }}} */ @@ -3268,10 +3261,10 @@ char *php_strerror(int errnum) /* {{{ php_stripcslashes */ -PHPAPI void php_stripcslashes(char *str, int *len) +PHPAPI void php_stripcslashes(char *str, php_size_t *len) { char *source, *target, *end; - int nlen = *len, i; + php_size_t nlen = *len, i; char numtmp[4]; for (source=str, end=str+nlen, target=str; source < end; source++) { @@ -3331,13 +3324,13 @@ PHPAPI void php_stripcslashes(char *str, int *len) /* {{{ php_addcslashes */ -PHPAPI zend_string *php_addcslashes(const char *str, int length, int should_free, char *what, int wlength TSRMLS_DC) +PHPAPI zend_string *php_addcslashes(const char *str, php_size_t length, int should_free, char *what, php_size_t wlength TSRMLS_DC) { char flags[256]; char *source, *target; char *end; char c; - int newlen; + php_size_t newlen; zend_string *new_str = STR_ALLOC(4 * (length? length : (length = strlen(str))), 0); if (!wlength) { @@ -3381,7 +3374,7 @@ PHPAPI zend_string *php_addcslashes(const char *str, int length, int should_free /* {{{ php_addslashes */ -PHPAPI zend_string *php_addslashes(char *str, int length, int should_free TSRMLS_DC) +PHPAPI zend_string *php_addslashes(char *str, php_size_t length, int should_free TSRMLS_DC) { /* maximum string length, worst case situation */ char *source, *target; @@ -4732,13 +4725,12 @@ PHP_FUNCTION(str_getcsv) Returns the input string repeat mult times */ PHP_FUNCTION(str_repeat) { - char *input_str; /* Input string */ - int input_len; - long mult; /* Multiplier */ + zend_string *input_str; /* Input string */ + php_int_t mult; /* Multiplier */ zend_string *result; /* Resulting string */ size_t result_len; /* Length of the resulting string */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &input_str, &input_len, &mult) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sl", &input_str, &mult) == FAILURE) { return; } @@ -4749,22 +4741,22 @@ PHP_FUNCTION(str_repeat) /* Don't waste our time if it's empty */ /* ... or if the multiplier is zero */ - if (input_len == 0 || mult == 0) + if (input_str->len == 0 || mult == 0) RETURN_EMPTY_STRING(); /* Initialize the result string */ - result = STR_SAFE_ALLOC(input_len, mult, 0, 0); - result_len = input_len * mult; + result = STR_SAFE_ALLOC(input_str->len, mult, 0, 0); + result_len = input_str->len * mult; /* Heavy optimization for situations where input string is 1 byte long */ - if (input_len == 1) { - memset(result->val, *(input_str), mult); + if (input_str->len == 1) { + memset(result->val, *(input_str->val), mult); } else { char *s, *e, *ee; - int l=0; - memcpy(result->val, input_str, input_len); + ptrdiff_t l=0; + memcpy(result->val, input_str->val, input_str->len); s = result->val; - e = result->val + input_len; + e = result->val + input_str->len; ee = result->val + result_len; while (e<ee) { diff --git a/ext/standard/var.c b/ext/standard/var.c index 1f86b1331b..fb82b50c5e 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -120,7 +120,7 @@ again: php_printf("%sNULL\n", COMMON); break; case IS_INT: - php_printf("%sint(%ld)\n", COMMON, Z_IVAL_P(struc)); + php_printf("%sint(" ZEND_INT_FMT ")\n", COMMON, Z_IVAL_P(struc)); break; case IS_DOUBLE: php_printf("%sfloat(%.*G)\n", COMMON, (int) EG(precision), Z_DVAL_P(struc)); @@ -291,7 +291,7 @@ again: php_printf("%sNULL\n", COMMON); break; case IS_INT: - php_printf("%slong(%ld)\n", COMMON, Z_IVAL_P(struc)); + php_printf("%slong(" ZEND_INT_FMT ")\n", COMMON, Z_IVAL_P(struc)); break; case IS_DOUBLE: php_printf("%sdouble(%.*G)\n", COMMON, (int) EG(precision), Z_DVAL_P(struc)); @@ -354,7 +354,7 @@ again: break; case IS_RESOURCE: { const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(struc) TSRMLS_CC); - php_printf("%sresource(%ld) of type (%s) refcount(%u)\n", COMMON, Z_RES_P(struc)->handle, type_name ? type_name : "Unknown", Z_REFCOUNT_P(struc)); + php_printf("%sresource(" ZEND_INT_FMT ") of type (%s) refcount(%u)\n", COMMON, Z_RES_P(struc)->handle, type_name ? type_name : "Unknown", Z_REFCOUNT_P(struc)); break; } case IS_REFERENCE: @@ -613,16 +613,16 @@ static inline int php_add_var_hash(HashTable *var_hash, zval *var_ptr, zval *var } if ((Z_TYPE_P(var) == IS_OBJECT) && Z_OBJ_HT_P(var)->get_class_entry) { p = smart_str_print_long(id + sizeof(id) - 1, - (long) Z_OBJ_P(var)); + (php_int_t) Z_OBJ_P(var)); *(--p) = 'O'; len = id + sizeof(id) - 1 - p; } else if (var_ptr != var) { p = smart_str_print_long(id + sizeof(id) - 1, - (long) Z_REF_P(var_ptr)); + (php_int_t) Z_REF_P(var_ptr)); *(--p) = 'R'; len = id + sizeof(id) - 1 - p; } else { - p = smart_str_print_long(id + sizeof(id) - 1, (long) var); + p = smart_str_print_long(id + sizeof(id) - 1, (php_int_t) var); len = id + sizeof(id) - 1 - p; } @@ -635,7 +635,7 @@ static inline int php_add_var_hash(HashTable *var_hash, zval *var_ptr, zval *var zend_hash_next_index_insert(var_hash, &var_no); } #if 0 - fprintf(stderr, "- had var (%d): %lu\n", Z_TYPE_P(var), **(ulong**)var_old); + fprintf(stderr, "- had var (%d): %lu\n", Z_TYPE_P(var), **(php_uint_t**)var_old); #endif return FAILURE; } @@ -650,7 +650,7 @@ static inline int php_add_var_hash(HashTable *var_hash, zval *var_ptr, zval *var } /* }}} */ -static inline void php_var_serialize_long(smart_str *buf, long val) /* {{{ */ +static inline void php_var_serialize_long(smart_str *buf, php_int_t val) /* {{{ */ { smart_str_appendl(buf, "i:", 2); smart_str_append_int(buf, val); @@ -928,7 +928,7 @@ again: if (i > 0) { zend_string *key; zval *data; - ulong index; + php_uint_t index; ZEND_HASH_FOREACH_KEY_VAL_IND(myht, index, key, data) { @@ -1031,7 +1031,7 @@ PHP_FUNCTION(unserialize) PHP_VAR_UNSERIALIZE_DESTROY(var_hash); zval_dtor(return_value); if (!EG(exception)) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Error at offset %ld of %d bytes", (long)((char*)p - buf), buf_len); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Error at offset " ZEND_INT_FMT " of %d bytes", (php_int_t)((char*)p - buf), buf_len); } RETURN_FALSE; } diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index 5636429c8b..8eef32308c 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -311,7 +311,7 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long return 0; } - if (Z_TYPE(key) != IS_LONG && Z_TYPE(key) != IS_STRING) { + if (Z_TYPE(key) != IS_INT && Z_TYPE(key) != IS_STRING) { zval_dtor(&key); return 0; } @@ -321,12 +321,12 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long if (!objprops) { switch (Z_TYPE(key)) { - case IS_LONG: - if ((old_data = zend_hash_index_find(ht, Z_LVAL(key))) != NULL) { + case IS_INT: + if ((old_data = zend_hash_index_find(ht, Z_IVAL(key))) != NULL) { //??? update hash var_push_dtor(var_hash, old_data); } - data = zend_hash_index_update(ht, Z_LVAL(key), &d); + data = zend_hash_index_update(ht, Z_IVAL(key), &d); break; case IS_STRING: if ((old_data = zend_symtable_find(ht, Z_STR(key))) != NULL) { @@ -552,9 +552,9 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) } /* Use double for large long values that were serialized on a 64-bit system */ - if (digits >= MAX_LENGTH_OF_LONG - 1) { - if (digits == MAX_LENGTH_OF_LONG - 1) { - int cmp = strncmp((char*)YYCURSOR - MAX_LENGTH_OF_LONG, long_min_digits, MAX_LENGTH_OF_LONG - 1); + if (digits >= MAX_LENGTH_OF_ZEND_INT - 1) { + if (digits == MAX_LENGTH_OF_ZEND_INT - 1) { + int cmp = strncmp((char*)YYCURSOR - MAX_LENGTH_OF_ZEND_INT, int_min_digits, MAX_LENGTH_OF_ZEND_INT - 1); if (!(cmp < 0 || (cmp == 0 && start[2] == '-'))) { goto use_double; @@ -565,7 +565,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) } #endif *p = YYCURSOR; - ZVAL_LONG(rval, parse_iv(start + 2)); + ZVAL_INT(rval, parse_iv(start + 2)); return 1; } |
