pollita Mon Oct 9 20:42:36 2006 UTC Modified files: /php-src/ext/gmp gmp.c /php-src/ext/gmp/tests 006.phpt 007.phpt 008.phpt 009.phpt gmp_nextprime.phpt Log: PHP6 Updates
http://cvs.php.net/viewvc.cgi/php-src/ext/gmp/gmp.c?r1=1.55&r2=1.56&diff_format=u Index: php-src/ext/gmp/gmp.c diff -u php-src/ext/gmp/gmp.c:1.55 php-src/ext/gmp/gmp.c:1.56 --- php-src/ext/gmp/gmp.c:1.55 Mon Jun 26 14:10:57 2006 +++ php-src/ext/gmp/gmp.c Mon Oct 9 20:42:35 2006 @@ -465,6 +465,9 @@ mpz_init_set_si(**gmpnumber, Z_LVAL_PP(val)); } break; + case IS_UNICODE: + convert_to_string_ex(val); + /* Fallthrough */ case IS_STRING: { char *numstr = Z_STRVAL_PP(val); @@ -478,6 +481,11 @@ base = 2; skip_lead = 1; } + /* Note: tests/004.phpt and tests/005.phpt suggest that we should be + * interpreting a leading zero as octal (when not followed by x or b) + * Yet the docs, and the existing code (above), suggest otherwise. + * + * Possibly fix this by putting an: else base = 8; here */ } } ret = mpz_init_set_str(**gmpnumber, (skip_lead ? &numstr[2] : numstr), base); @@ -748,7 +756,7 @@ } /* }}} */ -/* {{{ proto resource gmp_init(mixed number [, int base]) +/* {{{ proto resource gmp_init(mixed number [, int base]) U Initializes GMP number */ ZEND_FUNCTION(gmp_init) { @@ -780,7 +788,7 @@ } /* }}} */ -/* {{{ proto int gmp_intval(resource gmpnumber) +/* {{{ proto int gmp_intval(resource gmpnumber) U Gets signed long value of GMP number */ ZEND_FUNCTION(gmp_intval) { @@ -801,7 +809,7 @@ } /* }}} */ -/* {{{ proto string gmp_strval(resource gmpnumber [, int base]) +/* {{{ proto string gmp_strval(resource gmpnumber [, int base]) U Gets string representation of GMP number */ ZEND_FUNCTION(gmp_strval) { @@ -852,11 +860,11 @@ } else { out_string[num_len] = '\0'; } - RETVAL_STRINGL(out_string, num_len, 0); + RETVAL_RT_STRINGL(out_string, num_len, ZSTR_AUTOFREE); } /* }}} */ -/* {{{ proto resource gmp_add(resource a, resource b) +/* {{{ proto resource gmp_add(resource a, resource b) U Add a and b */ ZEND_FUNCTION(gmp_add) { @@ -864,7 +872,7 @@ } /* }}} */ -/* {{{ proto resource gmp_sub(resource a, resource b) +/* {{{ proto resource gmp_sub(resource a, resource b) U Subtract b from a */ ZEND_FUNCTION(gmp_sub) { @@ -872,7 +880,7 @@ } /* }}} */ -/* {{{ proto resource gmp_mul(resource a, resource b) +/* {{{ proto resource gmp_mul(resource a, resource b) U Multiply a and b */ ZEND_FUNCTION(gmp_mul) { @@ -880,7 +888,7 @@ } /* }}} */ -/* {{{ proto array gmp_div_qr(resource a, resource b [, int round]) +/* {{{ proto array gmp_div_qr(resource a, resource b [, int round]) U Divide a by b, returns quotient and reminder */ ZEND_FUNCTION(gmp_div_qr) { @@ -917,7 +925,7 @@ } /* }}} */ -/* {{{ proto resource gmp_div_r(resource a, resource b [, int round]) +/* {{{ proto resource gmp_div_r(resource a, resource b [, int round]) U Divide a by b, returns reminder only */ ZEND_FUNCTION(gmp_div_r) { @@ -953,7 +961,7 @@ } /* }}} */ -/* {{{ proto resource gmp_div_q(resource a, resource b [, int round]) +/* {{{ proto resource gmp_div_q(resource a, resource b [, int round]) U Divide a by b, returns quotient only */ ZEND_FUNCTION(gmp_div_q) { @@ -990,7 +998,7 @@ } /* }}} */ -/* {{{ proto resource gmp_mod(resource a, resource b) +/* {{{ proto resource gmp_mod(resource a, resource b) U Computes a modulo b */ ZEND_FUNCTION(gmp_mod) { @@ -1004,7 +1012,7 @@ } /* }}} */ -/* {{{ proto resource gmp_divexact(resource a, resource b) +/* {{{ proto resource gmp_divexact(resource a, resource b) U Divide a by b using exact division algorithm */ ZEND_FUNCTION(gmp_divexact) { @@ -1012,7 +1020,7 @@ } /* }}} */ -/* {{{ proto resource gmp_neg(resource a) +/* {{{ proto resource gmp_neg(resource a) U Negates a number */ ZEND_FUNCTION(gmp_neg) { @@ -1020,7 +1028,7 @@ } /* }}} */ -/* {{{ proto resource gmp_abs(resource a) +/* {{{ proto resource gmp_abs(resource a) U Calculates absolute value */ ZEND_FUNCTION(gmp_abs) { @@ -1028,7 +1036,7 @@ } /* }}} */ -/* {{{ proto resource gmp_fact(int a) +/* {{{ proto resource gmp_fact(int a) U Calculates factorial function */ ZEND_FUNCTION(gmp_fact) { @@ -1057,7 +1065,7 @@ } /* }}} */ -/* {{{ proto resource gmp_pow(resource base, int exp) +/* {{{ proto resource gmp_pow(resource base, int exp) U Raise base to power exp */ ZEND_FUNCTION(gmp_pow) { @@ -1093,7 +1101,7 @@ } /* }}} */ -/* {{{ proto resource gmp_powm(resource base, resource exp, resource mod) +/* {{{ proto resource gmp_powm(resource base, resource exp, resource mod) U Raise base to power exp and take result modulo mod */ ZEND_FUNCTION(gmp_powm) { @@ -1134,7 +1142,7 @@ } /* }}} */ -/* {{{ proto resource gmp_sqrt(resource a) +/* {{{ proto resource gmp_sqrt(resource a) U Takes integer part of square root of a */ ZEND_FUNCTION(gmp_sqrt) { @@ -1159,7 +1167,7 @@ } /* }}} */ -/* {{{ proto array gmp_sqrtrem(resource a) +/* {{{ proto array gmp_sqrtrem(resource a) U Square root with remainder */ ZEND_FUNCTION(gmp_sqrtrem) { @@ -1191,7 +1199,7 @@ } /* }}} */ -/* {{{ proto bool gmp_perfect_square(resource a) +/* {{{ proto bool gmp_perfect_square(resource a) U Checks if a is an exact square */ ZEND_FUNCTION(gmp_perfect_square) { @@ -1208,7 +1216,7 @@ } /* }}} */ -/* {{{ proto int gmp_prob_prime(resource a[, int reps]) +/* {{{ proto int gmp_prob_prime(resource a[, int reps]) U Checks if a is "probably prime" */ ZEND_FUNCTION(gmp_prob_prime) { @@ -1237,7 +1245,7 @@ } /* }}} */ -/* {{{ proto resource gmp_gcd(resource a, resource b) +/* {{{ proto resource gmp_gcd(resource a, resource b) U Computes greatest common denominator (gcd) of a and b */ ZEND_FUNCTION(gmp_gcd) { @@ -1251,7 +1259,7 @@ } /* }}} */ -/* {{{ proto array gmp_gcdext(resource a, resource b) +/* {{{ proto array gmp_gcdext(resource a, resource b) U Computes G, S, and T, such that AS + BT = G = `gcd' (A, B) */ ZEND_FUNCTION(gmp_gcdext) { @@ -1283,7 +1291,7 @@ } /* }}} */ -/* {{{ proto resource gmp_invert(resource a, resource b) +/* {{{ proto resource gmp_invert(resource a, resource b) U Computes the inverse of a modulo b */ ZEND_FUNCTION(gmp_invert) { @@ -1307,7 +1315,7 @@ } /* }}} */ -/* {{{ proto int gmp_jacobi(resource a, resource b) +/* {{{ proto int gmp_jacobi(resource a, resource b) U Computes Jacobi symbol */ ZEND_FUNCTION(gmp_jacobi) { @@ -1315,7 +1323,7 @@ } /* }}} */ -/* {{{ proto int gmp_legendre(resource a, resource b) +/* {{{ proto int gmp_legendre(resource a, resource b) U Computes Legendre symbol */ ZEND_FUNCTION(gmp_legendre) { @@ -1323,7 +1331,7 @@ } /* }}} */ -/* {{{ proto int gmp_cmp(resource a, resource b) +/* {{{ proto int gmp_cmp(resource a, resource b) U Compares two numbers */ ZEND_FUNCTION(gmp_cmp) { @@ -1353,7 +1361,7 @@ } /* }}} */ -/* {{{ proto int gmp_sign(resource a) +/* {{{ proto int gmp_sign(resource a) U Gets the sign of the number */ ZEND_FUNCTION(gmp_sign) { @@ -1370,7 +1378,7 @@ } /* }}} */ -/* {{{ proto resource gmp_random([int limiter]) +/* {{{ proto resource gmp_random([int limiter]) U Gets random number */ ZEND_FUNCTION(gmp_random) { @@ -1406,7 +1414,7 @@ } /* }}} */ -/* {{{ proto resource gmp_and(resource a, resource b) +/* {{{ proto resource gmp_and(resource a, resource b) U Calculates logical AND of a and b */ ZEND_FUNCTION(gmp_and) { @@ -1414,7 +1422,7 @@ } /* }}} */ -/* {{{ proto resource gmp_or(resource a, resource b) +/* {{{ proto resource gmp_or(resource a, resource b) U Calculates logical OR of a and b */ ZEND_FUNCTION(gmp_or) { @@ -1422,7 +1430,7 @@ } /* }}} */ -/* {{{ proto resource gmp_com(resource a) +/* {{{ proto resource gmp_com(resource a) U Calculates one's complement of a */ ZEND_FUNCTION(gmp_com) { @@ -1430,7 +1438,7 @@ } /* }}} */ -/* {{{ proto resource gmp_nextprime(resource a) +/* {{{ proto resource gmp_nextprime(resource a) U Finds next prime of a */ ZEND_FUNCTION(gmp_nextprime) { @@ -1438,7 +1446,7 @@ } /* }}} */ -/* {{{ proto resource gmp_xor(resource a, resource b) +/* {{{ proto resource gmp_xor(resource a, resource b) U Calculates logical exclusive OR of a and b */ ZEND_FUNCTION(gmp_xor) { @@ -1468,7 +1476,7 @@ } /* }}} */ -/* {{{ proto void gmp_setbit(resource &a, int index[, bool set_clear]) +/* {{{ proto void gmp_setbit(resource &a, int index[, bool set_clear]) U Sets or clear bit in a */ ZEND_FUNCTION(gmp_setbit) { @@ -1504,7 +1512,7 @@ } /* }}} */ -/* {{{ proto void gmp_clrbit(resource &a, int index) +/* {{{ proto void gmp_clrbit(resource &a, int index) U Clears bit in a */ ZEND_FUNCTION(gmp_clrbit) { @@ -1525,7 +1533,7 @@ } /* }}} */ -/* {{{ proto int gmp_popcount(resource a) +/* {{{ proto int gmp_popcount(resource a) U Calculates the population count of a */ ZEND_FUNCTION(gmp_popcount) { @@ -1542,7 +1550,7 @@ } /* }}} */ -/* {{{ proto int gmp_hamdist(resource a, resource b) +/* {{{ proto int gmp_hamdist(resource a, resource b) U Calculates hamming distance between a and b */ ZEND_FUNCTION(gmp_hamdist) { @@ -1560,7 +1568,7 @@ } /* }}} */ -/* {{{ proto int gmp_scan0(resource a, int start) +/* {{{ proto int gmp_scan0(resource a, int start) U Finds first zero bit */ ZEND_FUNCTION(gmp_scan0) { @@ -1578,7 +1586,7 @@ } /* }}} */ -/* {{{ proto int gmp_scan1(resource a, int start) +/* {{{ proto int gmp_scan1(resource a, int start) U Finds first non-zero bit */ ZEND_FUNCTION(gmp_scan1) { http://cvs.php.net/viewvc.cgi/php-src/ext/gmp/tests/006.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/gmp/tests/006.phpt diff -u php-src/ext/gmp/tests/006.phpt:1.1 php-src/ext/gmp/tests/006.phpt:1.2 --- php-src/ext/gmp/tests/006.phpt:1.1 Sun Sep 10 22:11:10 2006 +++ php-src/ext/gmp/tests/006.phpt Mon Oct 9 20:42:35 2006 @@ -36,15 +36,15 @@ Warning: gmp_sub(): Unable to convert variable to GMP - wrong type in %s on line %d bool(false) resource(%d) of type (GMP integer) -string(2) "-1" +%s(2) "-1" resource(%d) of type (GMP integer) -string(5) "10001" +%s(5) "10001" Warning: gmp_sub(): Unable to convert variable to GMP - wrong type in %s on line %d bool(false) -string(1) "0" +%s(1) "0" Warning: gmp_sub(): Unable to convert variable to GMP - wrong type in %s on line %d bool(false) -string(1) "0" +%s(1) "0" Done http://cvs.php.net/viewvc.cgi/php-src/ext/gmp/tests/007.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/gmp/tests/007.phpt diff -u php-src/ext/gmp/tests/007.phpt:1.1 php-src/ext/gmp/tests/007.phpt:1.2 --- php-src/ext/gmp/tests/007.phpt:1.1 Sun Sep 10 22:11:10 2006 +++ php-src/ext/gmp/tests/007.phpt Mon Oct 9 20:42:35 2006 @@ -56,8 +56,8 @@ [1]=> resource(%d) of type (GMP integer) } -string(1) "0" -string(1) "0" +%s(1) "0" +%s(1) "0" Warning: gmp_div_qr(): Zero operand not allowed in %s on line %d bool(false) @@ -67,8 +67,8 @@ [1]=> resource(%d) of type (GMP integer) } -string(1) "0" -string(5) "12653" +%s(1) "0" +%s(5) "12653" NULL Warning: gmp_strval(): Unable to convert variable to GMP - wrong type in %s on line %d @@ -82,48 +82,48 @@ [1]=> resource(%d) of type (GMP integer) } -string(4) "9131" -string(2) "10" +%s(4) "9131" +%s(2) "10" array(2) { [0]=> resource(%d) of type (GMP integer) [1]=> resource(%d) of type (GMP integer) } -string(4) "9132" -string(4) "-113" +%s(4) "9132" +%s(4) "-113" array(2) { [0]=> resource(%d) of type (GMP integer) [1]=> resource(%d) of type (GMP integer) } -string(4) "9131" -string(2) "10" +%s(4) "9131" +%s(2) "10" array(2) { [0]=> resource(%d) of type (GMP integer) [1]=> resource(%d) of type (GMP integer) } -string(4) "9131" -string(2) "10" +%s(4) "9131" +%s(2) "10" array(2) { [0]=> resource(%d) of type (GMP integer) [1]=> resource(%d) of type (GMP integer) } -string(4) "9132" -string(4) "-113" +%s(4) "9132" +%s(4) "-113" array(2) { [0]=> resource(%d) of type (GMP integer) [1]=> resource(%d) of type (GMP integer) } -string(4) "9131" -string(2) "10" +%s(4) "9131" +%s(2) "10" Warning: gmp_div_qr(): supplied resource is not a valid GMP integer resource in %s on line %d bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/gmp/tests/008.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/gmp/tests/008.phpt diff -u php-src/ext/gmp/tests/008.phpt:1.1 php-src/ext/gmp/tests/008.phpt:1.2 --- php-src/ext/gmp/tests/008.phpt:1.1 Sun Sep 10 22:11:10 2006 +++ php-src/ext/gmp/tests/008.phpt Mon Oct 9 20:42:35 2006 @@ -42,28 +42,28 @@ Warning: Wrong parameter count for gmp_div_r() in %s on line %d NULL int(0) -string(1) "0" +%s(1) "0" Warning: gmp_div_r(): Zero operand not allowed in %s on line %d bool(false) int(12653) -string(5) "12653" +%s(5) "12653" NULL Warning: gmp_strval(): Unable to convert variable to GMP - wrong type in %s on line %d bool(false) int(10) -string(2) "10" +%s(2) "10" int(113) -string(3) "113" +%s(3) "113" int(10) -string(2) "10" +%s(2) "10" int(10) -string(2) "10" +%s(2) "10" int(113) -string(3) "113" +%s(3) "113" int(10) -string(2) "10" +%s(2) "10" Warning: gmp_div_r(): supplied resource is not a valid GMP integer resource in %s on line %d bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/gmp/tests/009.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/gmp/tests/009.phpt diff -u php-src/ext/gmp/tests/009.phpt:1.1 php-src/ext/gmp/tests/009.phpt:1.2 --- php-src/ext/gmp/tests/009.phpt:1.1 Sun Sep 10 22:11:10 2006 +++ php-src/ext/gmp/tests/009.phpt Mon Oct 9 20:42:35 2006 @@ -42,28 +42,28 @@ Warning: Wrong parameter count for gmp_div_q() in %s on line %d NULL resource(%d) of type (GMP integer) -string(1) "0" +%s(1) "0" Warning: gmp_div_q(): Zero operand not allowed in %s on line %d bool(false) resource(%d) of type (GMP integer) -string(1) "0" +%s(1) "0" NULL Warning: gmp_strval(): Unable to convert variable to GMP - wrong type in %s on line %d bool(false) resource(%d) of type (GMP integer) -string(4) "9131" +%s(4) "9131" resource(%d) of type (GMP integer) -string(4) "9132" +%s(4) "9132" resource(%d) of type (GMP integer) -string(4) "9131" +%s(4) "9131" resource(%d) of type (GMP integer) -string(4) "9131" +%s(4) "9131" resource(%d) of type (GMP integer) -string(4) "9132" +%s(4) "9132" resource(%d) of type (GMP integer) -string(4) "9131" +%s(4) "9131" Warning: gmp_div_q(): supplied resource is not a valid GMP integer resource in %s on line %d bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/gmp/tests/gmp_nextprime.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/gmp/tests/gmp_nextprime.phpt diff -u php-src/ext/gmp/tests/gmp_nextprime.phpt:1.1 php-src/ext/gmp/tests/gmp_nextprime.phpt:1.2 --- php-src/ext/gmp/tests/gmp_nextprime.phpt:1.1 Mon Apr 3 18:11:56 2006 +++ php-src/ext/gmp/tests/gmp_nextprime.phpt Mon Oct 9 20:42:35 2006 @@ -25,16 +25,16 @@ echo "Done\n"; ?> --EXPECTF-- -string(1) "2" -string(1) "2" -string(4) "-997" -string(4) "1009" -string(6) "100003" +%s(1) "2" +%s(1) "2" +%s(4) "-997" +%s(4) "1009" +%s(6) "100003" Warning: gmp_nextprime(): Unable to convert variable to GMP - wrong type in %s on line %d -string(1) "0" -string(1) "0" +%s(1) "0" +%s(1) "0" Warning: gmp_nextprime(): Unable to convert variable to GMP - wrong type in %s on line %d -string(1) "0" +%s(1) "0" Done
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php