php-src/ext/bcmath
Arnaud Le Blanc efc8f0ebf8
Deprecate zend_atol() / add zend_ini_parse_quantity() (#7951)
Add zend_ini_parse_quantity() and deprecate zend_atol(), zend_atoi()

zend_atol() and zend_atoi() don't just do number parsing.
They also check for a 'K', 'M', or 'G' at the end of the string,
and multiply the parsed value out accordingly.

Unfortunately, they ignore any other non-numerics between the
numeric component and the last character in the string.
This means that numbers such as the following are both valid
and non-intuitive in their final output.

* "123KMG" is interpreted as "123G" -> 132070244352
* "123G " is interpreted as "123 " -> 123
* "123GB" is interpreted as "123B" -> 123
* "123 I like tacos." is also interpreted as "123." -> 123

Currently, in php-src these functions are used only for parsing ini values.

In this change we deprecate zend_atol(), zend_atoi(), and introduce a new
function with the same behavior, but with the ability to report invalid inputs
to the caller. The function's name also makes the behavior less unexpected:
zend_ini_parse_quantity().

Co-authored-by: Sara Golemon <pollita@php.net>
2022-06-17 14:12:53 +02:00
..
libbcmath Merge branch 'PHP-8.0' 2021-07-16 16:01:03 +02:00
tests Add some more test cases for BCMath 2021-12-30 13:02:56 +01:00
bcmath_arginfo.h Generate optimizer func info from stubs for a few extensions - part 2 (#7401) 2021-08-25 15:29:46 +02:00
bcmath.c Deprecate zend_atol() / add zend_ini_parse_quantity() (#7951) 2022-06-17 14:12:53 +02:00
bcmath.stub.php Generate optimizer func info from stubs for a few extensions - part 2 (#7401) 2021-08-25 15:29:46 +02:00
config.m4 Promote some warnings in BCMath to Errors 2020-09-11 17:40:06 +02:00
config.w32 Promote some warnings in BCMath to Errors 2020-09-11 17:40:06 +02:00
CREDITS
php_bcmath.h Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00