diff options
author | Matt Wilmas <mattwil@php.net> | 2009-06-04 18:20:45 +0000 |
---|---|---|
committer | Matt Wilmas <mattwil@php.net> | 2009-06-04 18:20:45 +0000 |
commit | b907aa43311ab0b5430d2713a54414baaf9c7e20 (patch) | |
tree | 397f1697ff3ff689eea6ff04611831939df02ef0 /Zend/zend_operators.c | |
parent | 1787a2272a7d9f3f7c7932f61b57054755e99135 (diff) | |
download | php-git-b907aa43311ab0b5430d2713a54414baaf9c7e20.tar.gz |
MFH:
Restored double->long conversion behavior to that of PHP 5.2 (on most platforms) and prior:
* Out-of-range numbers overflow/preserve least significant bits (no LONG_MAX/MIN limit)
* See bug #42868 (presumably-rare platform with different results in 5.2)
* On 32-bit platforms with 64-bit long type, a zend_long64 cast has been added,
otherwise it's the same as 5.2
* Use this conversion method everywhere instead of some plain (long) casts
Added 'L' parameter parsing specifier to ensure a LONG_MAX/MIN limit:
* Essentially what 5.3's new conversion was doing in most cases
* Functions with "limit" or "length" type params could be updated to use this,
and prevent confusing overflow behavior with huge numbers (*also* in 5.2)
- See bug #47854, for example; or even #42868 again
# Test updates coming
Diffstat (limited to 'Zend/zend_operators.c')
-rw-r--r-- | Zend/zend_operators.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 7b4919713f..ef08807c7d 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -225,7 +225,7 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC) /* {{{ */ Z_LVAL(holder) = 0; \ break; \ case IS_DOUBLE: \ - DVAL_TO_LVAL(Z_DVAL_P(op), Z_LVAL(holder)); \ + Z_LVAL(holder) = zend_dval_to_lval(Z_DVAL_P(op)); \ break; \ case IS_STRING: \ Z_LVAL(holder) = strtol(Z_STRVAL_P(op), NULL, 10); \ @@ -349,7 +349,7 @@ ZEND_API void convert_to_long_base(zval *op, int base) /* {{{ */ case IS_LONG: break; case IS_DOUBLE: - DVAL_TO_LVAL(Z_DVAL_P(op), Z_LVAL_P(op)); + Z_LVAL_P(op) = zend_dval_to_lval(Z_DVAL_P(op)); break; case IS_STRING: { @@ -1017,7 +1017,7 @@ ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC) /* {{{ */ ZVAL_LONG(result, ~Z_LVAL_P(op1)); return SUCCESS; } else if (Z_TYPE_P(op1) == IS_DOUBLE) { - ZVAL_LONG(result, ~(long) Z_DVAL_P(op1)); + ZVAL_LONG(result, ~zend_dval_to_lval(Z_DVAL_P(op1))); return SUCCESS; } else if (Z_TYPE_P(op1) == IS_STRING) { int i; |