]> granicus.if.org Git - php/commitdiff
Make gmp_setbit and gmp_clrbit return values consistent
authorLeigh <leight@gmail.com>
Wed, 24 Sep 2014 21:55:13 +0000 (22:55 +0100)
committerNikita Popov <nikic@php.net>
Sun, 28 Sep 2014 18:18:14 +0000 (20:18 +0200)
UPGRADING
ext/gmp/gmp.c
ext/gmp/tests/gmp_clrbit.phpt
ext/gmp/tests/gmp_setbit.phpt

index edd55b45451e5ae7eb90bb17279b46bfa2908f1a..dc2f8fedf79744a5aa29326676b0256d3bf1587b 100644 (file)
--- 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
 ========================================
index 18e79651994b424c6fad11b3cfd94982eab91a92..320ac3eb9223031bd47d0ab452e0fcad1ceee9f7 100644 (file)
@@ -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);
index 079d5d669f37b54b0385f70bca10814ce289eab4..0aab89dd37aeff4b292736e6e0897f91557dbbf2 100644 (file)
@@ -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
index 99848959d52df006f9f59e6ff84d424803c96340..2eac23db0edf8af104c14f9e4f6c02976855f4ce 100644 (file)
@@ -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"