php-src/ext/zlib
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
..
tests Merge branch 'PHP-8.0' into PHP-8.1 2022-02-03 16:13:11 +01:00
config0.m4 Normalize comments in *nix build system m4 files 2019-05-12 18:43:03 +02:00
config.w32 Sync leading and final newlines in source code files 2018-10-14 12:56:38 +02:00
CREDITS
php_zlib.def Export gzfwrite() 2021-04-26 12:09:31 +02:00
php_zlib.h Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
zlib_arginfo.h Generate optimizer func info from stubs for various extensions (#7409) 2021-08-26 19:52:11 +02:00
zlib_filter.c Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
zlib_fopen_wrapper.c Use memrchr() when available 2021-11-24 16:13:34 +03:00
zlib.c Deprecate zend_atol() / add zend_ini_parse_quantity() (#7951) 2022-06-17 14:12:53 +02:00
zlib.stub.php Generate optimizer func info from stubs for various extensions (#7409) 2021-08-26 19:52:11 +02:00