mirror of
https://github.com/php/php-src.git
synced 2024-12-14 20:33:36 +08:00
Remove old zend_string_to_double function
This commit is contained in:
parent
c48a126ba4
commit
f915b44070
@ -135,52 +135,6 @@ ZEND_API zend_long zend_atol(const char *str, int str_len) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API double zend_string_to_double(const char *number, uint32_t length) /* {{{ */
|
||||
{
|
||||
double divisor = 10.0;
|
||||
double result = 0.0;
|
||||
double exponent;
|
||||
const char *end = number+length;
|
||||
const char *digit = number;
|
||||
|
||||
if (!length) {
|
||||
return result;
|
||||
}
|
||||
|
||||
while (digit < end) {
|
||||
if ((*digit <= '9' && *digit >= '0')) {
|
||||
result *= 10;
|
||||
result += *digit - '0';
|
||||
} else if (*digit == '.') {
|
||||
digit++;
|
||||
break;
|
||||
} else if (toupper(*digit) == 'E') {
|
||||
exponent = (double) atoi(digit+1);
|
||||
result *= pow(10.0, exponent);
|
||||
return result;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
digit++;
|
||||
}
|
||||
|
||||
while (digit < end) {
|
||||
if ((*digit <= '9' && *digit >= '0')) {
|
||||
result += (*digit - '0') / divisor;
|
||||
divisor *= 10;
|
||||
} else if (toupper(*digit) == 'E') {
|
||||
exponent = (double) atoi(digit+1);
|
||||
result *= pow(10.0, exponent);
|
||||
return result;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
digit++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
try_again:
|
||||
|
@ -367,8 +367,6 @@ ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2
|
||||
#define convert_to_cstring(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_cstring((op) ZEND_FILE_LINE_CC); }
|
||||
#define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op) ZEND_FILE_LINE_CC); }
|
||||
|
||||
ZEND_API double zend_string_to_double(const char *number, uint32_t length);
|
||||
|
||||
ZEND_API int zval_is_true(zval *op);
|
||||
ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
|
Loading…
Reference in New Issue
Block a user