summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorMáté Kocsis <kocsismate@woohoolabs.com>2020-02-29 22:47:04 +0100
committerMáté Kocsis <kocsismate@woohoolabs.com>2020-05-08 10:52:23 +0200
commit4a816584a4d483722485e5163396ea1bb2a6aee7 (patch)
treed85d2f5a93b66da2b0b611cdb7600ae2b684ad7c /Zend
parent6e2cd97b4368e888193819dc0a6d1306b219ec21 (diff)
downloadphp-git-4a816584a4d483722485e5163396ea1bb2a6aee7.tar.gz
Make float to string casts locale-independent
From now on, float to string casting will always behave locale-independently. RFC: https://wiki.php.net/rfc/locale_independent_float_to_string Closes GH-5224 Co-authored-by: George Peter Banyard <girgias@php.net>
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_operators.c20
-rw-r--r--Zend/zend_operators.h2
2 files changed, 3 insertions, 19 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 012e95d3b2..562a0f6d54 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -605,20 +605,6 @@ try_again:
}
/* }}} */
-ZEND_API void ZEND_FASTCALL _convert_to_cstring(zval *op) /* {{{ */
-{
- if (Z_TYPE_P(op) == IS_DOUBLE) {
- zend_string *str;
- double dval = Z_DVAL_P(op);
-
- str = zend_strpprintf_unchecked(0, "%.*H", (int) EG(precision), dval);
- ZVAL_NEW_STR(op, str);
- } else {
- _convert_to_string(op);
- }
-}
-/* }}} */
-
ZEND_API void ZEND_FASTCALL _convert_to_string(zval *op) /* {{{ */
{
try_again:
@@ -648,8 +634,8 @@ try_again:
zend_string *str;
double dval = Z_DVAL_P(op);
- str = zend_strpprintf(0, "%.*G", (int) EG(precision), dval);
- /* %G already handles removing trailing zeros from the fractional part, yay */
+ str = zend_strpprintf_unchecked(0, "%.*H", (int) EG(precision), dval);
+
ZVAL_NEW_STR(op, str);
break;
}
@@ -953,7 +939,7 @@ try_again:
return zend_long_to_str(Z_LVAL_P(op));
}
case IS_DOUBLE: {
- return zend_strpprintf(0, "%.*G", (int) EG(precision), Z_DVAL_P(op));
+ return zend_strpprintf_unchecked(0, "%.*H", (int) EG(precision), Z_DVAL_P(op));
}
case IS_ARRAY:
zend_error(E_WARNING, "Array to string conversion");
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index 13f236bbaa..2c3766fd38 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -257,7 +257,6 @@ ZEND_API int ZEND_FASTCALL increment_function(zval *op1);
ZEND_API int ZEND_FASTCALL decrement_function(zval *op2);
ZEND_API void ZEND_FASTCALL convert_scalar_to_number(zval *op);
-ZEND_API void ZEND_FASTCALL _convert_to_cstring(zval *op);
ZEND_API void ZEND_FASTCALL _convert_to_string(zval *op);
ZEND_API void ZEND_FASTCALL convert_to_long(zval *op);
ZEND_API void ZEND_FASTCALL convert_to_double(zval *op);
@@ -340,7 +339,6 @@ static zend_always_inline zend_bool try_convert_to_string(zval *op) {
#define _zval_get_double_func(op) zval_get_double_func(op)
#define _zval_get_string_func(op) zval_get_string_func(op)
-#define convert_to_cstring(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_cstring((op)); }
#define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op)); }