mirror of
https://github.com/php/php-src.git
synced 2025-08-20 09:24:05 +02:00
Merge branch 'PHP-7.0'
* PHP-7.0: Correct intdiv() argument names and description
This commit is contained in:
commit
6571038093
2 changed files with 7 additions and 7 deletions
|
@ -1763,7 +1763,7 @@ ZEND_BEGIN_ARG_INFO(arginfo_fmod, 0)
|
|||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_intdiv, 0)
|
||||
ZEND_ARG_INFO(0, numerator)
|
||||
ZEND_ARG_INFO(0, dividend)
|
||||
ZEND_ARG_INFO(0, divisor)
|
||||
ZEND_END_ARG_INFO()
|
||||
/* }}} */
|
||||
|
|
|
@ -1456,27 +1456,27 @@ PHP_FUNCTION(fmod)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int intdiv(int numerator, int divisor)
|
||||
Returns the integer division of the numerator by the divisor */
|
||||
/* {{{ proto int intdiv(int dividend, int divisor)
|
||||
Returns the integer quotient of the division of dividend by divisor */
|
||||
PHP_FUNCTION(intdiv)
|
||||
{
|
||||
zend_long numerator, divisor;
|
||||
zend_long dividend, divisor;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &numerator, &divisor) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", ÷nd, &divisor) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (divisor == 0) {
|
||||
zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Division by zero");
|
||||
return;
|
||||
} else if (divisor == -1 && numerator == ZEND_LONG_MIN) {
|
||||
} else if (divisor == -1 && dividend == ZEND_LONG_MIN) {
|
||||
/* Prevent overflow error/crash ... really should not happen:
|
||||
We don't return a float here as that violates function contract */
|
||||
zend_throw_exception_ex(zend_ce_arithmetic_error, 0, "Division of PHP_INT_MIN by -1 is not an integer");
|
||||
return;
|
||||
}
|
||||
|
||||
RETURN_LONG(numerator / divisor);
|
||||
RETURN_LONG(dividend / divisor);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue