diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-06-03 10:12:21 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-06-03 10:14:05 +0200 |
commit | 321fe8893537f125befa5a59f7610d7ab01a5284 (patch) | |
tree | d0b40fd68016c030e351df0154e75ddeb6869fec /Zend/zend_API.c | |
parent | 8a0965e3d694037837a8f70f280e7d14dd7778eb (diff) | |
download | php-git-321fe8893537f125befa5a59f7610d7ab01a5284.tar.gz |
Add Z_PARAM_NUMBER and use it for some functions
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r-- | Zend/zend_API.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index d588266b42..c9c1654a62 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -381,6 +381,36 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest) / } /* }}} */ +ZEND_API int ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest) /* {{{ */ +{ + if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) { + return 0; + } + if (Z_TYPE_P(arg) == IS_STRING) { + zend_string *str = Z_STR_P(arg); + zend_long lval; + double dval; + zend_uchar type = is_numeric_string(ZSTR_VAL(str), ZSTR_LEN(str), &lval, &dval, -1); + if (type == IS_LONG) { + ZVAL_LONG(arg, lval); + } else if (type == IS_DOUBLE) { + ZVAL_DOUBLE(arg, dval); + } else { + return 0; + } + zend_string_release(str); + } else if (Z_TYPE_P(arg) < IS_TRUE) { + ZVAL_LONG(arg, 0); + } else if (Z_TYPE_P(arg) == IS_TRUE) { + ZVAL_LONG(arg, 1); + } else { + return 0; + } + *dest = arg; + return 1; +} +/* }}} */ + ZEND_API int ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest) /* {{{ */ { if (EXPECTED(Z_TYPE_P(arg) < IS_STRING)) { |