summaryrefslogtreecommitdiff
path: root/ext/bcmath/bcmath.c
diff options
context:
space:
mode:
authorGeorge Peter Banyard <girgias@php.net>2020-09-11 17:40:06 +0200
committerGeorge Peter Banyard <girgias@php.net>2020-09-11 17:40:06 +0200
commitcd05b56a6f7d4f03a80f86c15248eda995b1762e (patch)
treebe55bb068dc85f3d9c4853b22924356aa5a081a5 /ext/bcmath/bcmath.c
parentf29bfc0bd8c0dc152e6115ec260957e1617d08dc (diff)
downloadphp-git-cd05b56a6f7d4f03a80f86c15248eda995b1762e.tar.gz
Promote some warnings in BCMath to Errors
Also do a bit of refactoring at the same time. Closes GH-6105
Diffstat (limited to 'ext/bcmath/bcmath.c')
-rw-r--r--ext/bcmath/bcmath.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c
index 17f28f1781..f20dda534f 100644
--- a/ext/bcmath/bcmath.c
+++ b/ext/bcmath/bcmath.c
@@ -393,16 +393,8 @@ PHP_FUNCTION(bcpowmod)
php_str2num(&second, ZSTR_VAL(right));
php_str2num(&mod, ZSTR_VAL(modulus));
- switch (bc_raisemod(first, second, mod, &result, scale)) {
- case 0:
- RETVAL_STR(bc_num2str_ex(result, scale));
- break;
- case -1:
- zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
- break;
- case -2:
- zend_argument_value_error(2, "must be greater than 0");
- break;
+ if (bc_raisemod(first, second, mod, &result, scale) == SUCCESS) {
+ RETVAL_STR(bc_num2str_ex(result, scale));
}
bc_free_num(&first);
@@ -481,7 +473,7 @@ PHP_FUNCTION(bcsqrt)
if (bc_sqrt (&result, scale) != 0) {
RETVAL_STR(bc_num2str_ex(result, scale));
} else {
- zend_value_error("Square root of negative number");
+ zend_argument_value_error(1, "must be greater than or equal to 0");
}
bc_free_num(&result);