From: Sara Golemon Date: Mon, 9 Oct 2006 20:42:35 +0000 (+0000) Subject: PHP6 Updates X-Git-Tag: RELEASE_1_0_0RC1~1329 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71a765c651594ac5b6d0654ce4959e3e0d496c96;p=php PHP6 Updates --- diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 34a6b68ba7..83d807d5f3 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -465,6 +465,9 @@ static int convert_to_gmp(mpz_t * *gmpnumber, zval **val, int base TSRMLS_DC) 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 @@ static int convert_to_gmp(mpz_t * *gmpnumber, zval **val, int base TSRMLS_DC) 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 @@ static inline void _gmp_binary_opl(INTERNAL_FUNCTION_PARAMETERS, gmp_binary_opl_ } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_init) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_intval) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_strval) } 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 @@ ZEND_FUNCTION(gmp_add) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_sub) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_mul) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_div_qr) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_div_r) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_div_q) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_mod) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_divexact) } /* }}} */ -/* {{{ proto resource gmp_neg(resource a) +/* {{{ proto resource gmp_neg(resource a) U Negates a number */ ZEND_FUNCTION(gmp_neg) { @@ -1020,7 +1028,7 @@ ZEND_FUNCTION(gmp_neg) } /* }}} */ -/* {{{ proto resource gmp_abs(resource a) +/* {{{ proto resource gmp_abs(resource a) U Calculates absolute value */ ZEND_FUNCTION(gmp_abs) { @@ -1028,7 +1036,7 @@ ZEND_FUNCTION(gmp_abs) } /* }}} */ -/* {{{ proto resource gmp_fact(int a) +/* {{{ proto resource gmp_fact(int a) U Calculates factorial function */ ZEND_FUNCTION(gmp_fact) { @@ -1057,7 +1065,7 @@ ZEND_FUNCTION(gmp_fact) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_pow) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_powm) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_sqrt) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_sqrtrem) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_perfect_square) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_prob_prime) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_gcd) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_gcdext) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_invert) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_jacobi) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_legendre) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_cmp) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_sign) } /* }}} */ -/* {{{ proto resource gmp_random([int limiter]) +/* {{{ proto resource gmp_random([int limiter]) U Gets random number */ ZEND_FUNCTION(gmp_random) { @@ -1406,7 +1414,7 @@ ZEND_FUNCTION(gmp_random) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_and) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_or) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_com) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_nextprime) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_xor) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_setbit) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_clrbit) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_popcount) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_hamdist) } /* }}} */ -/* {{{ 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 @@ ZEND_FUNCTION(gmp_scan0) } /* }}} */ -/* {{{ 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) { diff --git a/ext/gmp/tests/006.phpt b/ext/gmp/tests/006.phpt index 2e207c197b..0b94bf7eab 100644 --- a/ext/gmp/tests/006.phpt +++ b/ext/gmp/tests/006.phpt @@ -36,15 +36,15 @@ NULL 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 diff --git a/ext/gmp/tests/007.phpt b/ext/gmp/tests/007.phpt index d699816103..adcb88b246 100644 --- a/ext/gmp/tests/007.phpt +++ b/ext/gmp/tests/007.phpt @@ -56,8 +56,8 @@ array(2) { [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 @@ array(2) { [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 @@ array(2) { [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) diff --git a/ext/gmp/tests/008.phpt b/ext/gmp/tests/008.phpt index 773719ec4d..ebd17794d3 100644 --- a/ext/gmp/tests/008.phpt +++ b/ext/gmp/tests/008.phpt @@ -42,28 +42,28 @@ NULL 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) diff --git a/ext/gmp/tests/009.phpt b/ext/gmp/tests/009.phpt index 559cc17f2d..b5f782fa80 100644 --- a/ext/gmp/tests/009.phpt +++ b/ext/gmp/tests/009.phpt @@ -42,28 +42,28 @@ NULL 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) diff --git a/ext/gmp/tests/gmp_nextprime.phpt b/ext/gmp/tests/gmp_nextprime.phpt index 84d945b3fc..ce15ccac75 100644 --- a/ext/gmp/tests/gmp_nextprime.phpt +++ b/ext/gmp/tests/gmp_nextprime.phpt @@ -25,16 +25,16 @@ var_dump(gmp_strval($n)); 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