From: Antony Dovgal Date: Wed, 25 Apr 2007 18:09:08 +0000 (+0000) Subject: add GMP_VERSION constant X-Git-Tag: RELEASE_1_2_0~219 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9acfe7288fe71f749eb414804f12fb1d2a9783e0;p=php add GMP_VERSION constant add test do not allow zero operand in gmp_divexact() --- diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index ef1f44214b..c213f6dfe7 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -396,6 +396,7 @@ ZEND_MODULE_STARTUP_D(gmp) REGISTER_LONG_CONSTANT("GMP_ROUND_ZERO", GMP_ROUND_ZERO, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GMP_ROUND_PLUSINF", GMP_ROUND_PLUSINF, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GMP_ROUND_MINUSINF", GMP_ROUND_MINUSINF, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("GMP_VERSION", (char *)gmp_version, CONST_CS | CONST_PERSISTENT); mp_set_memory_functions(gmp_emalloc, gmp_erealloc, gmp_efree); @@ -422,6 +423,7 @@ ZEND_MODULE_INFO_D(gmp) { php_info_print_table_start(); php_info_print_table_row(2, "gmp support", "enabled"); + php_info_print_table_row(2, "GMP version", gmp_version); php_info_print_table_end(); } /* }}} */ @@ -1011,7 +1013,13 @@ ZEND_FUNCTION(gmp_mod) Divide a by b using exact division algorithm */ ZEND_FUNCTION(gmp_divexact) { - gmp_binary_op(mpz_divexact); + zval **a_arg, **b_arg; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &a_arg, &b_arg) == FAILURE){ + WRONG_PARAM_COUNT; + } + + gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_divexact, NULL, 0, 1 TSRMLS_CC); } /* }}} */ diff --git a/ext/gmp/tests/011.phpt b/ext/gmp/tests/011.phpt new file mode 100644 index 0000000000..a6fb7c8833 --- /dev/null +++ b/ext/gmp/tests/011.phpt @@ -0,0 +1,52 @@ +--TEST-- +gmp_divexact() tests (OK to fail with GMP =< 4.2.1) +--FILE-- + +--EXPECTF-- +string(1) "0" + +Warning: gmp_divexact(): Zero operand not allowed in %s on line %d +string(1) "0" +string(2) "10" +string(3) "512" +string(19) "5000000000000000000" +string(18) "200000000000000000" +string(9) "-10000000" +Done +--UEXPECTF-- +unicode(1) "0" + +Warning: gmp_divexact(): Zero operand not allowed in %s on line %d +unicode(1) "0" +unicode(2) "10" +unicode(3) "512" +unicode(19) "5000000000000000000" +unicode(18) "200000000000000000" +unicode(9) "-10000000" +Done