tony2001 Thu Apr 26 13:44:02 2007 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/gmp/tests 011.phpt
Modified files:
/php-src NEWS
/php-src/ext/gmp gmp.c
Log:
MFH: add test & GMP_VERSION constant
do not allow zero operand in gmp_divexact()
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.662&r2=1.2027.2.547.2.663&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.662 php-src/NEWS:1.2027.2.547.2.663
--- php-src/NEWS:1.2027.2.547.2.662 Tue Apr 24 13:54:59 2007
+++ php-src/NEWS Thu Apr 26 13:44:01 2007
@@ -1,6 +1,7 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? Apr 2007, PHP 5.2.2RC2
+- Added GMP_VERSION constant. (Tony)
- Fixed commandline handling fro CLI and CGI. (Marcus, Johannes)
- Upgraded SQLite 3 to version 3.3.16 (Ilia)
- Updated timezone database to version 2007.5. (Derick)
http://cvs.php.net/viewvc.cgi/php-src/ext/gmp/gmp.c?r1=1.49.2.2.2.10&r2=1.49.2.2.2.11&diff_format=u
Index: php-src/ext/gmp/gmp.c
diff -u php-src/ext/gmp/gmp.c:1.49.2.2.2.10 php-src/ext/gmp/gmp.c:1.49.2.2.2.11
--- php-src/ext/gmp/gmp.c:1.49.2.2.2.10 Wed Apr 18 20:53:28 2007
+++ php-src/ext/gmp/gmp.c Thu Apr 26 13:44:02 2007
@@ -389,6 +389,7 @@
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);
@@ -415,6 +416,7 @@
{
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();
}
/* }}} */
@@ -996,7 +998,13 @@
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);
}
/* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/gmp/tests/011.phpt?view=markup&rev=1.1
Index: php-src/ext/gmp/tests/011.phpt
+++ php-src/ext/gmp/tests/011.phpt
--TEST--
gmp_divexact() tests (OK to fail with GMP =< 4.2.1)
--FILE--
<?php
$r = gmp_divexact("233", "23345555555555555555555555");
var_dump(gmp_strval($r));
$r = gmp_divexact("233", "0");
var_dump(gmp_strval($r));
$r = gmp_divexact("100", "10");
var_dump(gmp_strval($r));
$r = gmp_divexact("1024", "2");
var_dump(gmp_strval($r));
$n = gmp_init("10000000000000000000");
$r = gmp_divexact($n, "2");
var_dump(gmp_strval($r));
$r = gmp_divexact($n, "50");
var_dump(gmp_strval($r));
$n1 = gmp_init("-100000000000000000000000000");
$r = gmp_divexact($n1, $n);
var_dump(gmp_strval($r));
echo "Done\n";
?>
--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
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php