com php-src: added ZEND_ABS and revamped some related stuff: Zend/zend_int.h ext/date/php_date.c e xt/standard/array.c
| From: | Anatol Belski | Date: | Sun, 29 Dec 2013 15:39:15 +0000 |
| Subject: | com php-src: added ZEND_ABS and revamped some related stuff: Zend/zend_int.h ext/date/php_date.c e xt/standard/array.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75489@lists.php.net to get a copy of this message | ||
Commit: b923ee32c9d2c2ecb28de86bca00721ff2448af8
Author: Anatol Belski <ab@php.net> Sun, 29 Dec 2013 16:39:15 +0100
Parents: 1085d216939f02791045bb1fcd409e3bab8bee07
Branches: str_size_and_int64
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b923ee32c9d2c2ecb28de86bca00721ff2448af8
Log:
added ZEND_ABS and revamped some related stuff
Changed paths:
M Zend/zend_int.h
M ext/date/php_date.c
M ext/standard/array.c
Diff:
diff --git a/Zend/zend_int.h b/Zend/zend_int.h
index 4bf7370..4621f9b 100644
--- a/Zend/zend_int.h
+++ b/Zend/zend_int.h
@@ -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
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index ef07952..d00a0a0 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -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; \
} \
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 3623cf0..e7b28a8 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -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;