diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2017-09-06 14:28:51 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2017-09-06 14:28:51 +0200 |
commit | cf61ec64a4f1aedf244e052e5e633c7ef009f145 (patch) | |
tree | 86b600052aa46cb4ab452796ec5c79e4c8bc6019 /ext/bcmath/bcmath.c | |
parent | 8e6619445f0029ade97581839f99645215a416c4 (diff) | |
parent | 1e3435b2898ea2b9e16ca92064edd8fa1a07b44c (diff) | |
download | php-git-cf61ec64a4f1aedf244e052e5e633c7ef009f145.tar.gz |
Merge branch 'pull-request/778' into bcscale-return-old-value
Diffstat (limited to 'ext/bcmath/bcmath.c')
-rw-r--r-- | ext/bcmath/bcmath.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c index e8b87dceff..6020a7c6d7 100644 --- a/ext/bcmath/bcmath.c +++ b/ext/bcmath/bcmath.c @@ -581,15 +581,20 @@ PHP_FUNCTION(bccomp) Sets default scale parameter for all bc math functions */ PHP_FUNCTION(bcscale) { - zend_long new_scale; + zend_long old_scale, new_scale; - ZEND_PARSE_PARAMETERS_START(1, 1) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL Z_PARAM_LONG(new_scale) ZEND_PARSE_PARAMETERS_END(); + old_scale = BCG(bc_precision); + + if (ZEND_NUM_ARGS() == 1) { BCG(bc_precision) = ((int)new_scale < 0) ? 0 : new_scale; + } - RETURN_TRUE; + RETURN_LONG(old_scale); } /* }}} */ |