mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-26 18:35:42 +00:00
added ZEND_ABS and revamped some related stuff
This commit is contained in:
1 parent
1085d21693
commit
b923ee32c9
3 files changed
+8
-19
No files matched your search
@@ -91,6 +91,7 @@ typedef long zend_off_t;
|
||||
# define ZEND_UINT_FMT_SPEC "I64u"
|
||||
# define ZEND_STRTOL_PTR _strtoi64
|
||||
# define ZEND_STRTOUL_PTR _strtoui64
|
||||
# define ZEND_ABS _abs64
|
||||
# else
|
||||
# define ZEND_ITOA(i, s, len) \
|
||||
do { \
|
||||
@@ -106,6 +107,7 @@ typedef long zend_off_t;
|
||||
# define ZEND_UINT_FMT_SPEC "llu"
|
||||
# define ZEND_STRTOL_PTR strtoll
|
||||
# define ZEND_STRTOUL_PTR strtoull
|
||||
# define ZEND_ABS llabs
|
||||
# endif
|
||||
#else
|
||||
# define ZEND_STRTOL(s0, s1, base) strtol((s0), (s1), (base))
|
||||
@@ -127,6 +129,7 @@ typedef long zend_off_t;
|
||||
# define ZEND_UINT_FMT_SPEC "lu"
|
||||
# define ZEND_STRTOL_PTR strtol
|
||||
# define ZEND_STRTOUL_PTR strtoul
|
||||
# define ZEND_ABS abs
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
+1
-15
@@ -39,20 +39,6 @@ static __inline __int64_t php_date_llabs( __int64_t i ) { return i >= 0 ? i : -i
|
||||
static inline long long php_date_llabs( long long i ) { return i >= 0 ? i : -i; }
|
||||
#endif
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
#define DATE_I64_BUF_LEN 65
|
||||
# define DATE_I64A(i, s, len) _i64toa_s(i, s, len, 10)
|
||||
# define DATE_A64I(i, s) i = _atoi64(s)
|
||||
#else
|
||||
#define DATE_I64_BUF_LEN 65
|
||||
# define DATE_I64A(i, s, len) \
|
||||
do { \
|
||||
int st = snprintf(s, len, "%lld", i); \
|
||||
s[st] = '\0'; \
|
||||
} while (0);
|
||||
# define DATE_A64I(i, s) i = atoll(s)
|
||||
#endif
|
||||
|
||||
/* {{{ arginfo */
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_date, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, format)
|
||||
@@ -4200,7 +4186,7 @@ static int php_date_interval_initialize_from_hash(zval **return_value, php_inter
|
||||
zval **z_arg = NULL; \
|
||||
if (zend_hash_find(myht, element, strlen(element) + 1, (void**) &z_arg) == SUCCESS) { \
|
||||
convert_to_string(*z_arg); \
|
||||
DATE_A64I((*intobj)->diff->member, Z_STRVAL_PP(z_arg)); \
|
||||
ZEND_ATOI((*intobj)->diff->member, Z_STRVAL_PP(z_arg)); \
|
||||
} else { \
|
||||
(*intobj)->diff->member = -1LL; \
|
||||
} \
|
||||
|
||||
@@ -1748,7 +1748,7 @@ static void php_array_data_shuffle(zval *array TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
Bucket **elems, *temp;
|
||||
HashTable *hash;
|
||||
int j, n_elems, rnd_idx, n_left;
|
||||
php_int_t j, n_elems, rnd_idx, n_left;
|
||||
|
||||
n_elems = zend_hash_num_elements(Z_ARRVAL_P(array));
|
||||
|
||||
@@ -2692,7 +2692,7 @@ PHP_FUNCTION(array_pad)
|
||||
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 */
|
||||
php_int_t num_pads; /* How many pads do we need */
|
||||
int do_pad; /* Whether we should do padding at all */
|
||||
int i;
|
||||
|
||||
@@ -2702,7 +2702,7 @@ PHP_FUNCTION(array_pad)
|
||||
|
||||
/* 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);
|
||||
@@ -2720,7 +2720,7 @@ PHP_FUNCTION(array_pad)
|
||||
|
||||
/* Populate the pads array */
|
||||
num_pads = pad_size_abs - input_size;
|
||||
if (num_pads > 1048576) {
|
||||
if (num_pads > Z_I(1048576)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "You may only pad up to 1048576 elements at a time");
|
||||
zval_dtor(return_value);
|
||||
RETURN_FALSE;
|
||||
|
||||
Reference in new issue
Block a user