mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Remove zend_atoi() (#7232)
It's the same as (int) zend_atol() -- it doesn't try to do anything integer size specific. Canonicalize to one function in preparation for renaming zend_atol() to something less misleading. FFI test is adjusted to use a zend_test function. It just calls zend_atol() internally, but could really be anything. Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
This commit is contained in:
parent
497858a043
commit
1cba7764b4
@ -91,34 +91,6 @@ static const unsigned char tolower_map[256] = {
|
||||
zend_binary_strncasecmp
|
||||
*/
|
||||
|
||||
ZEND_API int ZEND_FASTCALL zend_atoi(const char *str, size_t str_len) /* {{{ */
|
||||
{
|
||||
int retval;
|
||||
|
||||
if (!str_len) {
|
||||
str_len = strlen(str);
|
||||
}
|
||||
retval = ZEND_STRTOL(str, NULL, 0);
|
||||
if (str_len>0) {
|
||||
switch (str[str_len-1]) {
|
||||
case 'g':
|
||||
case 'G':
|
||||
retval *= 1024;
|
||||
ZEND_FALLTHROUGH;
|
||||
case 'm':
|
||||
case 'M':
|
||||
retval *= 1024;
|
||||
ZEND_FALLTHROUGH;
|
||||
case 'k':
|
||||
case 'K':
|
||||
retval *= 1024;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API zend_long ZEND_FASTCALL zend_atol(const char *str, size_t str_len) /* {{{ */
|
||||
{
|
||||
zend_long retval;
|
||||
|
@ -458,7 +458,6 @@ ZEND_API int ZEND_FASTCALL zend_compare_symbol_tables(HashTable *ht1, HashTable
|
||||
ZEND_API int ZEND_FASTCALL zend_compare_arrays(zval *a1, zval *a2);
|
||||
ZEND_API int ZEND_FASTCALL zend_compare_objects(zval *o1, zval *o2);
|
||||
|
||||
ZEND_API int ZEND_FASTCALL zend_atoi(const char *str, size_t str_len);
|
||||
ZEND_API zend_long ZEND_FASTCALL zend_atol(const char *str, size_t str_len);
|
||||
|
||||
#define convert_to_null_ex(zv) convert_to_null(zv)
|
||||
|
@ -2,6 +2,7 @@
|
||||
FR #78270 (Usage of __vectorcall convention with FFI)
|
||||
--EXTENSIONS--
|
||||
ffi
|
||||
zend_test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (substr(PHP_OS, 0, 3) != 'WIN') die("skip this test is for Windows platforms only");
|
||||
@ -14,8 +15,8 @@ if (preg_match('/Compiler => .*clang.*/', $info)) die("skip not for clang");
|
||||
|
||||
try {
|
||||
FFI::cdef(<<<EOC
|
||||
__vectorcall int zend_atoi(const char *str, size_t str_len);
|
||||
EOC, ffi_get_php_dll_name());
|
||||
__vectorcall int bug78270(const char *str, size_t str_len);
|
||||
EOC, "php_zend_test.dll");
|
||||
} catch (FFI\ParserException $ex) {
|
||||
die('skip __vectorcall not supported');
|
||||
}
|
||||
@ -24,9 +25,9 @@ try {
|
||||
<?php
|
||||
require_once('utils.inc');
|
||||
$ffi = FFI::cdef(<<<EOC
|
||||
__vectorcall int zend_atoi(const char *str, size_t str_len);
|
||||
EOC, ffi_get_php_dll_name());
|
||||
var_dump($ffi->zend_atoi("17.4", 4));
|
||||
__vectorcall int bug78270(const char *str, size_t str_len);
|
||||
EOC, "php_zend_test.dll");
|
||||
var_dump($ffi->bug78270("17.4", 4));
|
||||
?>
|
||||
--EXPECT--
|
||||
int(17)
|
||||
|
@ -2,6 +2,7 @@
|
||||
FR #78270 (Usage of __vectorcall convention with FFI)
|
||||
--EXTENSIONS--
|
||||
ffi
|
||||
zend_test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (substr(PHP_OS, 0, 3) != 'WIN') die("skip this test is for Windows platforms only");
|
||||
@ -9,8 +10,8 @@ if (substr(PHP_OS, 0, 3) != 'WIN') die("skip this test is for Windows platforms
|
||||
require_once('utils.inc');
|
||||
try {
|
||||
FFI::cdef(<<<EOC
|
||||
__vectorcall int zend_atoi(const char *str, size_t str_len);
|
||||
EOC, ffi_get_php_dll_name());
|
||||
__vectorcall int bug78270(const char *str, size_t str_len);
|
||||
EOC, "php_zend_test.dll");
|
||||
} catch (FFI\ParserException $ex) {
|
||||
die('skip __vectorcall not supported');
|
||||
}
|
||||
|
@ -67,6 +67,8 @@ struct bug79096 {
|
||||
# define PHP_ZEND_TEST_API
|
||||
#endif
|
||||
|
||||
PHP_ZEND_TEST_API int ZEND_FASTCALL bug78270(const char *str, size_t str_len);
|
||||
|
||||
PHP_ZEND_TEST_API struct bug79096 bug79096(void);
|
||||
PHP_ZEND_TEST_API void bug79532(off_t *array, size_t elems);
|
||||
|
||||
|
@ -469,6 +469,12 @@ ZEND_TSRMLS_CACHE_DEFINE()
|
||||
ZEND_GET_MODULE(zend_test)
|
||||
#endif
|
||||
|
||||
/* The important part here is the ZEND_FASTCALL. */
|
||||
PHP_ZEND_TEST_API int ZEND_FASTCALL bug78270(const char *str, size_t str_len)
|
||||
{
|
||||
return (int) zend_atol(str, str_len);
|
||||
}
|
||||
|
||||
PHP_ZEND_TEST_API struct bug79096 bug79096(void)
|
||||
{
|
||||
struct bug79096 b;
|
||||
|
@ -1278,7 +1278,7 @@ static PHP_INI_MH(OnUpdate_zlib_output_compression)
|
||||
} else if (zend_string_equals_literal_ci(new_value, "on")) {
|
||||
int_value = 1;
|
||||
} else {
|
||||
int_value = zend_atoi(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
|
||||
int_value = (int) zend_atol(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
|
||||
}
|
||||
ini_value = zend_ini_string("output_handler", sizeof("output_handler"), 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user