com php-src: Make gmp_setbit and gmp_clrbit return values consistent: UPGRADING ext/gmp/gmp.c ext/gmp/ tests/gmp_clrbit.phpt
ext/gmp/tests/gmp_setbit.phpt
| From: | Nikita Popov | Date: | Sun, 28 Sep 2014 18:18:14 +0000 |
| Subject: | com php-src: Make gmp_setbit and gmp_clrbit return values consistent: UPGRADING ext/gmp/gmp.c ext/gmp/ tests/gmp_clrbit.phpt ext/gmp/tests/gmp_setbit.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-81994@lists.php.net to get a copy of this message | ||
Commit: 581c86c07fdbd37dbe22825282f9fc498f959ad6
Author: Leigh <leight@gmail.com> Wed, 24 Sep 2014 22:55:13 +0100
Committer: Nikita Popov <nikic@php.net> Sun, 28 Sep 2014 20:18:14 +0200
Parents: 4b3e19802385c5874eefd3ba4565f2efbc55dc96
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=581c86c07fdbd37dbe22825282f9fc498f959ad6
Log:
Make gmp_setbit and gmp_clrbit return values consistent
Changed paths:
M UPGRADING
M ext/gmp/gmp.c
M ext/gmp/tests/gmp_clrbit.phpt
M ext/gmp/tests/gmp_setbit.phpt
Diff:
diff --git a/UPGRADING b/UPGRADING
index edd55b4..dc2f8fe 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -31,9 +31,13 @@ PHP X.Y UPGRADE NOTES
around.
- DBA
- . dba_delete() now returns false if the key was not found for the inifile
+ . dba_delete() now returns false if the key was not found for the inifile
handler, too.
+- GMP
+ . gmp_setbit() and gmp_clrbit() now return FALSE for negative indices, making
+ them consistent with other GMP functions.
+
========================================
2. New Features
========================================
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c
index 18e7965..320ac3e 100644
--- a/ext/gmp/gmp.c
+++ b/ext/gmp/gmp.c
@@ -1849,7 +1849,7 @@ ZEND_FUNCTION(gmp_setbit)
if (index < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Index must be greater than or equal to
zero");
- return;
+ RETURN_FALSE;
}
gmpnum_a = GET_GMP_FROM_ZVAL(a_arg);
@@ -1876,7 +1876,7 @@ ZEND_FUNCTION(gmp_clrbit)
if (index < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Index must be greater than or equal to
zero");
- return;
+ RETURN_FALSE;
}
gmpnum_a = GET_GMP_FROM_ZVAL(a_arg);
diff --git a/ext/gmp/tests/gmp_clrbit.phpt b/ext/gmp/tests/gmp_clrbit.phpt
index 079d5d6..0aab89d 100644
--- a/ext/gmp/tests/gmp_clrbit.phpt
+++ b/ext/gmp/tests/gmp_clrbit.phpt
@@ -10,7 +10,7 @@ gmp_clrbit($n, 0);
var_dump(gmp_strval($n));
$n = gmp_init(-1);
-gmp_clrbit($n, -1);
+var_dump(gmp_clrbit($n, -1));
var_dump(gmp_strval($n));
$n = gmp_init("1000000");
@@ -35,10 +35,11 @@ gmp_clrbit();
echo "Done\n";
?>
---EXPECTF--
+--EXPECTF--
string(1) "0"
Warning: gmp_clrbit(): Index must be greater than or equal to zero in %s on line %d
+bool(false)
string(2) "-1"
Warning: gmp_clrbit(): Index must be greater than or equal to zero in %s on line %d
diff --git a/ext/gmp/tests/gmp_setbit.phpt b/ext/gmp/tests/gmp_setbit.phpt
index 9984895..2eac23d 100644
--- a/ext/gmp/tests/gmp_setbit.phpt
+++ b/ext/gmp/tests/gmp_setbit.phpt
@@ -10,7 +10,7 @@ gmp_setbit($n, 10, -1);
var_dump(gmp_strval($n));
$n = gmp_init(5);
-gmp_setbit($n, -20, 0);
+var_dump(gmp_setbit($n, -20, 0));
var_dump(gmp_strval($n));
$n = gmp_init(5);
@@ -41,10 +41,11 @@ gmp_setbit($a,array());
echo "Done\n";
?>
---EXPECTF--
+--EXPECTF--
string(2) "-1"
Warning: gmp_setbit(): Index must be greater than or equal to zero in %s on line %d
+bool(false)
string(1) "5"
string(1) "1"
string(1) "7"