diff options
-rw-r--r-- | ext/gmp/gmp.c | 5 | ||||
-rw-r--r-- | ext/gmp/tests/001.phpt | 21 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_abs.phpt (renamed from ext/gmp/tests/013.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_and.phpt (renamed from ext/gmp/tests/029.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_clrbit.phpt (renamed from ext/gmp/tests/034.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_cmp.phpt (renamed from ext/gmp/tests/026.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_com.phpt (renamed from ext/gmp/tests/031.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_div_q.phpt (renamed from ext/gmp/tests/009.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_div_qr.phpt (renamed from ext/gmp/tests/007.phpt) | 17 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_div_r.phpt (renamed from ext/gmp/tests/008.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_divexact.phpt (renamed from ext/gmp/tests/011.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_export.phpt | 80 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_fact.phpt (renamed from ext/gmp/tests/014.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_gcd.phpt (renamed from ext/gmp/tests/021.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_gcdext.phpt (renamed from ext/gmp/tests/022.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_hamdist.phpt (renamed from ext/gmp/tests/036.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_import.phpt (renamed from ext/gmp/tests/import-export.phpt) | 70 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_init.phpt (renamed from ext/gmp/tests/040.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_intval.phpt (renamed from ext/gmp/tests/004.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_invert.phpt (renamed from ext/gmp/tests/023.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_jacobi.phpt (renamed from ext/gmp/tests/024.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_legendre.phpt (renamed from ext/gmp/tests/025.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_mod.phpt (renamed from ext/gmp/tests/010.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_neg.phpt (renamed from ext/gmp/tests/012.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_or.phpt (renamed from ext/gmp/tests/030.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_perfect_square.phpt (renamed from ext/gmp/tests/019.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_popcount.phpt (renamed from ext/gmp/tests/035.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_pow.phpt (renamed from ext/gmp/tests/015.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_pown.phpt (renamed from ext/gmp/tests/016.phpt) | 9 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_prob_prime.phpt (renamed from ext/gmp/tests/020.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_random.phpt (renamed from ext/gmp/tests/028.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_remroot.phpt (renamed from ext/gmp/tests/041.phpt) | 49 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_root.phpt | 58 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_scan0.phpt (renamed from ext/gmp/tests/037.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_scan1.phpt (renamed from ext/gmp/tests/038.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_setbit.phpt (renamed from ext/gmp/tests/033.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_sign.phpt (renamed from ext/gmp/tests/027.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_sqrt.phpt (renamed from ext/gmp/tests/017.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_sqrtrem.phpt (renamed from ext/gmp/tests/018.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_strval.phpt (renamed from ext/gmp/tests/005.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_sub.phpt (renamed from ext/gmp/tests/006.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_testbit.phpt (renamed from ext/gmp/tests/039.phpt) | 5 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_xor.phpt (renamed from ext/gmp/tests/032.phpt) | 0 | ||||
-rw-r--r-- | ext/gmp/tests/overloading.phpt | 60 | ||||
-rw-r--r-- | sapi/litespeed/lsapi_main.c | 68 | ||||
-rw-r--r-- | sapi/litespeed/lsapilib.c | 6 |
46 files changed, 299 insertions, 149 deletions
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 3b58212902..7eb9eef494 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -1451,10 +1451,9 @@ ZEND_FUNCTION(gmp_powm) FETCH_GMP_ZVAL_DEP_DEP(gmpnum_mod, mod_arg, temp_mod, temp_exp, temp_base); if (!mpz_cmp_ui(gmpnum_mod, 0)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Modulus may not be zero"); FREE_GMP_TEMP(temp_base); - if (use_ui) { - FREE_GMP_TEMP(temp_exp); - } + FREE_GMP_TEMP(temp_exp); FREE_GMP_TEMP(temp_mod); RETURN_FALSE; } diff --git a/ext/gmp/tests/001.phpt b/ext/gmp/tests/001.phpt deleted file mode 100644 index 5126f73142..0000000000 --- a/ext/gmp/tests/001.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Check for gmp presence ---SKIPIF-- -<?php if (!extension_loaded("gmp")) print "skip"; ?> ---FILE-- -<?php -echo "gmp extension is available"; -/* - you can add regression tests for your extension here - - the output of your test code has to be equal to the - text in the --EXPECT-- section below for the tests - to pass, differences between the output and the - expected text are interpreted as failure - - see php5/tests/README for further information on - writing regression tests -*/ -?> ---EXPECT-- -gmp extension is available diff --git a/ext/gmp/tests/013.phpt b/ext/gmp/tests/gmp_abs.phpt index bb35891f2a..bb35891f2a 100644 --- a/ext/gmp/tests/013.phpt +++ b/ext/gmp/tests/gmp_abs.phpt diff --git a/ext/gmp/tests/029.phpt b/ext/gmp/tests/gmp_and.phpt index 9bc401031b..9bc401031b 100644 --- a/ext/gmp/tests/029.phpt +++ b/ext/gmp/tests/gmp_and.phpt diff --git a/ext/gmp/tests/034.phpt b/ext/gmp/tests/gmp_clrbit.phpt index 079d5d669f..079d5d669f 100644 --- a/ext/gmp/tests/034.phpt +++ b/ext/gmp/tests/gmp_clrbit.phpt diff --git a/ext/gmp/tests/026.phpt b/ext/gmp/tests/gmp_cmp.phpt index 83e7910d1e..83e7910d1e 100644 --- a/ext/gmp/tests/026.phpt +++ b/ext/gmp/tests/gmp_cmp.phpt diff --git a/ext/gmp/tests/031.phpt b/ext/gmp/tests/gmp_com.phpt index 1e0c1b4694..1e0c1b4694 100644 --- a/ext/gmp/tests/031.phpt +++ b/ext/gmp/tests/gmp_com.phpt diff --git a/ext/gmp/tests/009.phpt b/ext/gmp/tests/gmp_div_q.phpt index 3b75a48e18..3b75a48e18 100644 --- a/ext/gmp/tests/009.phpt +++ b/ext/gmp/tests/gmp_div_q.phpt diff --git a/ext/gmp/tests/007.phpt b/ext/gmp/tests/gmp_div_qr.phpt index e391c121f8..90099249db 100644 --- a/ext/gmp/tests/007.phpt +++ b/ext/gmp/tests/gmp_div_qr.phpt @@ -10,11 +10,13 @@ var_dump(gmp_div_qr("")); var_dump(gmp_div_qr(0,1)); var_dump(gmp_div_qr(1,0)); +var_dump(gmp_div_qr(gmp_init(1), gmp_init(0))); var_dump(gmp_div_qr(12653,23482734)); var_dump(gmp_div_qr(12653,23482734, 10)); var_dump(gmp_div_qr(1123123,123)); var_dump(gmp_div_qr(1123123,123, 1)); var_dump(gmp_div_qr(1123123,123, 2)); +var_dump(gmp_div_qr(gmp_init(1123123), gmp_init(123))); var_dump(gmp_div_qr(1123123,123, GMP_ROUND_ZERO)); var_dump(gmp_div_qr(1123123,123, GMP_ROUND_PLUSINF)); var_dump(gmp_div_qr(1123123,123, GMP_ROUND_MINUSINF)); @@ -47,6 +49,9 @@ array(2) { Warning: gmp_div_qr(): Zero operand not allowed in %s on line %d bool(false) + +Warning: gmp_div_qr(): Zero operand not allowed in %s on line %d +bool(false) array(2) { [0]=> object(GMP)#%d (1) { @@ -114,6 +119,18 @@ array(2) { [0]=> object(GMP)#%d (1) { ["num"]=> + string(4) "9131" + } + [1]=> + object(GMP)#%d (1) { + ["num"]=> + string(2) "10" + } +} +array(2) { + [0]=> + object(GMP)#%d (1) { + ["num"]=> string(4) "9132" } [1]=> diff --git a/ext/gmp/tests/008.phpt b/ext/gmp/tests/gmp_div_r.phpt index c1874c86f9..c1874c86f9 100644 --- a/ext/gmp/tests/008.phpt +++ b/ext/gmp/tests/gmp_div_r.phpt diff --git a/ext/gmp/tests/011.phpt b/ext/gmp/tests/gmp_divexact.phpt index a42c1b6b4e..a42c1b6b4e 100644 --- a/ext/gmp/tests/011.phpt +++ b/ext/gmp/tests/gmp_divexact.phpt diff --git a/ext/gmp/tests/gmp_export.phpt b/ext/gmp/tests/gmp_export.phpt new file mode 100644 index 0000000000..fbc8901cfc --- /dev/null +++ b/ext/gmp/tests/gmp_export.phpt @@ -0,0 +1,80 @@ +--TEST-- +gmp_export() basic tests +--SKIPIF-- +<?php if (!extension_loaded("gmp")) echo "skip"; ?> +--FILE-- +<?php + +// Tests taken from GMPs own test suite. + +// format is [output, size, options, expected] +$export = [ + ['0',1,GMP_BIG_ENDIAN,''], + ['0',2,GMP_BIG_ENDIAN,''], + ['0',3,GMP_BIG_ENDIAN,''], + ['12345678',1,GMP_BIG_ENDIAN,'12345678'], + ['12345678',4,GMP_BIG_ENDIAN,'12345678'], + ['12345678',4,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'12345678'], + ['12345678',1,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'78563412'], + ['12345678',4,GMP_LITTLE_ENDIAN,'78563412'], + ['12345678',4,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'78563412'], + ['123456789ABC',2,GMP_BIG_ENDIAN,'123456789abc'], + ['123456789ABC',2,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'9abc56781234'], + ['123456789ABC',2,GMP_LITTLE_ENDIAN,'34127856bc9a'], + ['123456789ABC',2,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'bc9a78563412'], + ['112233445566778899AABBCC',4,GMP_BIG_ENDIAN,'112233445566778899aabbcc'], + ['112233445566778899AABBCC',4,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'99aabbcc5566778811223344'], + ['112233445566778899AABBCC',4,GMP_LITTLE_ENDIAN,'4433221188776655ccbbaa99'], + ['112233445566778899AABBCC',4,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'ccbbaa998877665544332211'], + ['100120023003400450056006700780089009A00AB00BC00C',8,GMP_BIG_ENDIAN,'100120023003400450056006700780089009a00ab00bc00c'], + ['100120023003400450056006700780089009A00AB00BC00C',8,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'9009a00ab00bc00c50056006700780081001200230034004'], + ['100120023003400450056006700780089009A00AB00BC00C',8,GMP_LITTLE_ENDIAN,'044003300220011008800770066005500cc00bb00aa00990'], + ['100120023003400450056006700780089009A00AB00BC00C',8,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'0cc00bb00aa0099008800770066005500440033002200110'] +]; + +$passed = true; +foreach ($export as $k => $test) { + $gmp = gmp_init($test[0], 16); + $str = gmp_export($gmp, $test[1], $test[2]); + if (is_string($str)) { + $result = bin2hex($str); + if ($result !== $test[3]) { + echo "$k: '$result' !== '{$test[3]}'\n"; + $passed = false; + } + } else { + $type = gettype($str); + echo "$k: $type !== '{$test[3]}'\n"; + } +} + +var_dump($passed); + +// Invalid arguments (zpp failure) +var_dump(gmp_export()); + +// Invalid word sizes +var_dump(gmp_export(123, -1)); +var_dump(gmp_export(123, 0)); + +// Invalid options +var_dump(gmp_export(123, 1, GMP_MSW_FIRST | GMP_LSW_FIRST)); +var_dump(gmp_export(123, 1, GMP_BIG_ENDIAN | GMP_LITTLE_ENDIAN)); + +--EXPECTF-- +bool(true) + +Warning: gmp_export() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Warning: gmp_export(): Word size must be positive, -1 given in %s on line %d +bool(false) + +Warning: gmp_export(): Word size must be positive, 0 given in %s on line %d +bool(false) + +Warning: gmp_export(): Invalid options: Conflicting word orders in %s on line %d +bool(false) + +Warning: gmp_export(): Invalid options: Conflicting word endianness in %s on line %d +bool(false) diff --git a/ext/gmp/tests/014.phpt b/ext/gmp/tests/gmp_fact.phpt index 6afccaf936..6afccaf936 100644 --- a/ext/gmp/tests/014.phpt +++ b/ext/gmp/tests/gmp_fact.phpt diff --git a/ext/gmp/tests/021.phpt b/ext/gmp/tests/gmp_gcd.phpt index 275f0bca35..275f0bca35 100644 --- a/ext/gmp/tests/021.phpt +++ b/ext/gmp/tests/gmp_gcd.phpt diff --git a/ext/gmp/tests/022.phpt b/ext/gmp/tests/gmp_gcdext.phpt index 469aa3013d..469aa3013d 100644 --- a/ext/gmp/tests/022.phpt +++ b/ext/gmp/tests/gmp_gcdext.phpt diff --git a/ext/gmp/tests/036.phpt b/ext/gmp/tests/gmp_hamdist.phpt index c21e03ccb2..c21e03ccb2 100644 --- a/ext/gmp/tests/036.phpt +++ b/ext/gmp/tests/gmp_hamdist.phpt diff --git a/ext/gmp/tests/import-export.phpt b/ext/gmp/tests/gmp_import.phpt index 00632517e9..b7ae6600ed 100644 --- a/ext/gmp/tests/import-export.phpt +++ b/ext/gmp/tests/gmp_import.phpt @@ -1,5 +1,5 @@ --TEST-- -Check gmp_import and gmp_export behave as intended +gmp_import() basic tests --SKIPIF-- <?php if (!extension_loaded("gmp")) echo "skip"; ?> --FILE-- @@ -30,32 +30,6 @@ $import = [ ['100120023003400450056006700780089009a00ab00bc00c',8,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'0cc00bb00aa0099008800770066005500440033002200110'] ]; -// format is [output, size, options, expected] -$export = [ - ['0',1,GMP_BIG_ENDIAN,''], - ['0',2,GMP_BIG_ENDIAN,''], - ['0',3,GMP_BIG_ENDIAN,''], - ['12345678',1,GMP_BIG_ENDIAN,'12345678'], - ['12345678',4,GMP_BIG_ENDIAN,'12345678'], - ['12345678',4,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'12345678'], - ['12345678',1,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'78563412'], - ['12345678',4,GMP_LITTLE_ENDIAN,'78563412'], - ['12345678',4,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'78563412'], - ['123456789ABC',2,GMP_BIG_ENDIAN,'123456789abc'], - ['123456789ABC',2,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'9abc56781234'], - ['123456789ABC',2,GMP_LITTLE_ENDIAN,'34127856bc9a'], - ['123456789ABC',2,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'bc9a78563412'], - ['112233445566778899AABBCC',4,GMP_BIG_ENDIAN,'112233445566778899aabbcc'], - ['112233445566778899AABBCC',4,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'99aabbcc5566778811223344'], - ['112233445566778899AABBCC',4,GMP_LITTLE_ENDIAN,'4433221188776655ccbbaa99'], - ['112233445566778899AABBCC',4,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'ccbbaa998877665544332211'], - ['100120023003400450056006700780089009A00AB00BC00C',8,GMP_BIG_ENDIAN,'100120023003400450056006700780089009a00ab00bc00c'], - ['100120023003400450056006700780089009A00AB00BC00C',8,GMP_LSW_FIRST | GMP_BIG_ENDIAN,'9009a00ab00bc00c50056006700780081001200230034004'], - ['100120023003400450056006700780089009A00AB00BC00C',8,GMP_LITTLE_ENDIAN,'044003300220011008800770066005500cc00bb00aa00990'], - ['100120023003400450056006700780089009A00AB00BC00C',8,GMP_LSW_FIRST | GMP_LITTLE_ENDIAN,'0cc00bb00aa0099008800770066005500440033002200110'] -]; - -echo "Import:\n"; $passed = true; foreach ($import as $k => $test) { $gmp = gmp_import(hex2bin($test[3]), $test[1], $test[2]); @@ -73,30 +47,12 @@ foreach ($import as $k => $test) { var_dump($passed); -echo "\nExport:\n"; -$passed = true; -foreach ($export as $k => $test) { - $gmp = gmp_init($test[0], 16); - $str = gmp_export($gmp, $test[1], $test[2]); - if (is_string($str)) { - $result = bin2hex($str); - if ($result !== $test[3]) { - echo "$k: '$result' !== '{$test[3]}'\n"; - $passed = false; - } - } else { - $type = gettype($str); - echo "$k: $type !== '{$test[3]}'\n"; - } -} - -var_dump($passed); +// Invalid arguments (zpp failure) +var_dump(gmp_import()); // Invalid word sizes var_dump(gmp_import('a', -1)); var_dump(gmp_import('a', 0)); -var_dump(gmp_export(123, -1)); -var_dump(gmp_export(123, 0)); // Invalid data lengths var_dump(gmp_import('a', 2)); @@ -107,15 +63,11 @@ var_dump(gmp_import(str_repeat('a', 100), 64)); var_dump(gmp_import('a', 1, GMP_MSW_FIRST | GMP_LSW_FIRST)); var_dump(gmp_import('a', 1, GMP_BIG_ENDIAN | GMP_LITTLE_ENDIAN)); -var_dump(gmp_export(123, 1, GMP_MSW_FIRST | GMP_LSW_FIRST)); -var_dump(gmp_export(123, 1, GMP_BIG_ENDIAN | GMP_LITTLE_ENDIAN)); - --EXPECTF-- -Import: bool(true) -Export: -bool(true) +Warning: gmp_import() expects at least 1 parameter, 0 given in %s on line %d +NULL Warning: gmp_import(): Word size must be positive, -1 given in %s on line %d bool(false) @@ -123,12 +75,6 @@ bool(false) Warning: gmp_import(): Word size must be positive, 0 given in %s on line %d bool(false) -Warning: gmp_export(): Word size must be positive, -1 given in %s on line %d -bool(false) - -Warning: gmp_export(): Word size must be positive, 0 given in %s on line %d -bool(false) - Warning: gmp_import(): Input length must be a multiple of word size in %s on line %d bool(false) @@ -143,9 +89,3 @@ bool(false) Warning: gmp_import(): Invalid options: Conflicting word endianness in %s on line %d bool(false) - -Warning: gmp_export(): Invalid options: Conflicting word orders in %s on line %d -bool(false) - -Warning: gmp_export(): Invalid options: Conflicting word endianness in %s on line %d -bool(false) diff --git a/ext/gmp/tests/040.phpt b/ext/gmp/tests/gmp_init.phpt index 29640ba704..29640ba704 100644 --- a/ext/gmp/tests/040.phpt +++ b/ext/gmp/tests/gmp_init.phpt diff --git a/ext/gmp/tests/004.phpt b/ext/gmp/tests/gmp_intval.phpt index 088dd08fd8..088dd08fd8 100644 --- a/ext/gmp/tests/004.phpt +++ b/ext/gmp/tests/gmp_intval.phpt diff --git a/ext/gmp/tests/023.phpt b/ext/gmp/tests/gmp_invert.phpt index 81a90fe16a..81a90fe16a 100644 --- a/ext/gmp/tests/023.phpt +++ b/ext/gmp/tests/gmp_invert.phpt diff --git a/ext/gmp/tests/024.phpt b/ext/gmp/tests/gmp_jacobi.phpt index 04ddba4f08..04ddba4f08 100644 --- a/ext/gmp/tests/024.phpt +++ b/ext/gmp/tests/gmp_jacobi.phpt diff --git a/ext/gmp/tests/025.phpt b/ext/gmp/tests/gmp_legendre.phpt index 6dde34e1e7..6dde34e1e7 100644 --- a/ext/gmp/tests/025.phpt +++ b/ext/gmp/tests/gmp_legendre.phpt diff --git a/ext/gmp/tests/010.phpt b/ext/gmp/tests/gmp_mod.phpt index 12e7cad2b3..12e7cad2b3 100644 --- a/ext/gmp/tests/010.phpt +++ b/ext/gmp/tests/gmp_mod.phpt diff --git a/ext/gmp/tests/012.phpt b/ext/gmp/tests/gmp_neg.phpt index 8ca3471cb8..8ca3471cb8 100644 --- a/ext/gmp/tests/012.phpt +++ b/ext/gmp/tests/gmp_neg.phpt diff --git a/ext/gmp/tests/030.phpt b/ext/gmp/tests/gmp_or.phpt index 035f070bd7..035f070bd7 100644 --- a/ext/gmp/tests/030.phpt +++ b/ext/gmp/tests/gmp_or.phpt diff --git a/ext/gmp/tests/019.phpt b/ext/gmp/tests/gmp_perfect_square.phpt index aa596ba9cd..aa596ba9cd 100644 --- a/ext/gmp/tests/019.phpt +++ b/ext/gmp/tests/gmp_perfect_square.phpt diff --git a/ext/gmp/tests/035.phpt b/ext/gmp/tests/gmp_popcount.phpt index 4b45a04481..4b45a04481 100644 --- a/ext/gmp/tests/035.phpt +++ b/ext/gmp/tests/gmp_popcount.phpt diff --git a/ext/gmp/tests/015.phpt b/ext/gmp/tests/gmp_pow.phpt index e17ecc7bad..e17ecc7bad 100644 --- a/ext/gmp/tests/015.phpt +++ b/ext/gmp/tests/gmp_pow.phpt diff --git a/ext/gmp/tests/016.phpt b/ext/gmp/tests/gmp_pown.phpt index 8a0b34458f..f5857b6995 100644 --- a/ext/gmp/tests/016.phpt +++ b/ext/gmp/tests/gmp_pown.phpt @@ -19,6 +19,9 @@ var_dump(gmp_strval(gmp_powm($n,$e,1000))); $m = gmp_init(900); var_dump(gmp_strval(gmp_powm($n,$e,$m))); +var_dump(gmp_powm(5, 11, 0)); +var_dump(gmp_powm(5, "11", gmp_init(0))); + var_dump(gmp_powm(array(),$e,$m)); var_dump(gmp_powm($n,array(),$m)); var_dump(gmp_powm($n,$e,array())); @@ -46,6 +49,12 @@ string(3) "331" string(3) "171" string(3) "371" +Warning: gmp_powm(): Modulus may not be zero in %s on line %d +bool(false) + +Warning: gmp_powm(): Modulus may not be zero in %s on line %d +bool(false) + Warning: gmp_powm(): Unable to convert variable to GMP - wrong type in %s on line %d bool(false) diff --git a/ext/gmp/tests/020.phpt b/ext/gmp/tests/gmp_prob_prime.phpt index f8f3e6921c..f8f3e6921c 100644 --- a/ext/gmp/tests/020.phpt +++ b/ext/gmp/tests/gmp_prob_prime.phpt diff --git a/ext/gmp/tests/028.phpt b/ext/gmp/tests/gmp_random.phpt index 3a876aa60c..3a876aa60c 100644 --- a/ext/gmp/tests/028.phpt +++ b/ext/gmp/tests/gmp_random.phpt diff --git a/ext/gmp/tests/041.phpt b/ext/gmp/tests/gmp_remroot.phpt index 6e6d959288..4a3539d87c 100644 --- a/ext/gmp/tests/041.phpt +++ b/ext/gmp/tests/gmp_remroot.phpt @@ -1,21 +1,11 @@ --TEST-- -gmp_root() and gmp_rootrem() basic tests +gmp_rootrem() basic tests --SKIPIF-- <?php if (!extension_loaded("gmp")) print "skip"; ?> --FILE-- <?php -var_dump(gmp_root(1000, 3)); -var_dump(gmp_root(100, 3)); -var_dump(gmp_root(-100, 3)); - -var_dump(gmp_root(1000, 4)); -var_dump(gmp_root(100, 4)); -var_dump(gmp_root(-100, 4)); - -var_dump(gmp_root(0, 3)); -var_dump(gmp_root(100, 0)); -var_dump(gmp_root(100, -3)); +var_dump(gmp_rootrem()); var_dump(gmp_rootrem(1000, 3)); var_dump(gmp_rootrem(100, 3)); @@ -31,39 +21,8 @@ var_dump(gmp_rootrem(100, -3)); ?> --EXPECTF-- -object(GMP)#%d (1) { - ["num"]=> - string(2) "10" -} -object(GMP)#%d (1) { - ["num"]=> - string(1) "4" -} -object(GMP)#%d (1) { - ["num"]=> - string(2) "-4" -} -object(GMP)#%d (1) { - ["num"]=> - string(1) "5" -} -object(GMP)#%d (1) { - ["num"]=> - string(1) "3" -} - -Warning: gmp_root(): Can't take even root of negative number in %s on line %d -bool(false) -object(GMP)#%d (1) { - ["num"]=> - string(1) "0" -} - -Warning: gmp_root(): The root must be positive in %s on line %d -bool(false) - -Warning: gmp_root(): The root must be positive in %s on line %d -bool(false) +Warning: gmp_rootrem() expects exactly 2 parameters, 0 given in %s on line %d +NULL array(2) { [0]=> object(GMP)#%d (1) { diff --git a/ext/gmp/tests/gmp_root.phpt b/ext/gmp/tests/gmp_root.phpt new file mode 100644 index 0000000000..70faf27051 --- /dev/null +++ b/ext/gmp/tests/gmp_root.phpt @@ -0,0 +1,58 @@ +--TEST-- +gmp_root() basic tests +--SKIPIF-- +<?php if (!extension_loaded("gmp")) print "skip"; ?> +--FILE-- +<?php + +var_dump(gmp_root()); + +var_dump(gmp_root(1000, 3)); +var_dump(gmp_root(100, 3)); +var_dump(gmp_root(-100, 3)); + +var_dump(gmp_root(1000, 4)); +var_dump(gmp_root(100, 4)); +var_dump(gmp_root(-100, 4)); + +var_dump(gmp_root(0, 3)); +var_dump(gmp_root(100, 0)); +var_dump(gmp_root(100, -3)); + +?> +--EXPECTF-- +Warning: gmp_root() expects exactly 2 parameters, 0 given in %s on line %d +NULL +object(GMP)#%d (1) { + ["num"]=> + string(2) "10" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "4" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "-4" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "5" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "3" +} + +Warning: gmp_root(): Can't take even root of negative number in %s on line %d +bool(false) +object(GMP)#%d (1) { + ["num"]=> + string(1) "0" +} + +Warning: gmp_root(): The root must be positive in %s on line %d +bool(false) + +Warning: gmp_root(): The root must be positive in %s on line %d +bool(false) diff --git a/ext/gmp/tests/037.phpt b/ext/gmp/tests/gmp_scan0.phpt index 2a87a968a2..2a87a968a2 100644 --- a/ext/gmp/tests/037.phpt +++ b/ext/gmp/tests/gmp_scan0.phpt diff --git a/ext/gmp/tests/038.phpt b/ext/gmp/tests/gmp_scan1.phpt index 7ebce9be7d..7ebce9be7d 100644 --- a/ext/gmp/tests/038.phpt +++ b/ext/gmp/tests/gmp_scan1.phpt diff --git a/ext/gmp/tests/033.phpt b/ext/gmp/tests/gmp_setbit.phpt index 99848959d5..99848959d5 100644 --- a/ext/gmp/tests/033.phpt +++ b/ext/gmp/tests/gmp_setbit.phpt diff --git a/ext/gmp/tests/027.phpt b/ext/gmp/tests/gmp_sign.phpt index 1efdc28c6f..1efdc28c6f 100644 --- a/ext/gmp/tests/027.phpt +++ b/ext/gmp/tests/gmp_sign.phpt diff --git a/ext/gmp/tests/017.phpt b/ext/gmp/tests/gmp_sqrt.phpt index d90f538213..d90f538213 100644 --- a/ext/gmp/tests/017.phpt +++ b/ext/gmp/tests/gmp_sqrt.phpt diff --git a/ext/gmp/tests/018.phpt b/ext/gmp/tests/gmp_sqrtrem.phpt index 2fca463daa..2fca463daa 100644 --- a/ext/gmp/tests/018.phpt +++ b/ext/gmp/tests/gmp_sqrtrem.phpt diff --git a/ext/gmp/tests/005.phpt b/ext/gmp/tests/gmp_strval.phpt index 79fd73ecf8..79fd73ecf8 100644 --- a/ext/gmp/tests/005.phpt +++ b/ext/gmp/tests/gmp_strval.phpt diff --git a/ext/gmp/tests/006.phpt b/ext/gmp/tests/gmp_sub.phpt index e1d9df67db..e1d9df67db 100644 --- a/ext/gmp/tests/006.phpt +++ b/ext/gmp/tests/gmp_sub.phpt diff --git a/ext/gmp/tests/039.phpt b/ext/gmp/tests/gmp_testbit.phpt index 399c511370..ab40abed7f 100644 --- a/ext/gmp/tests/039.phpt +++ b/ext/gmp/tests/gmp_testbit.phpt @@ -5,6 +5,8 @@ gmp_testbit() basic tests --FILE-- <?php +var_dump(gmp_testbit()); + $n = gmp_init(0); var_dump(gmp_testbit($n, -10)); var_dump(gmp_testbit($n, 0)); @@ -38,6 +40,9 @@ var_dump(gmp_strval($n)); echo "Done\n"; ?> --EXPECTF-- +Warning: gmp_testbit() expects exactly 2 parameters, 0 given in %s on line %d +NULL + Warning: gmp_testbit(): Index must be greater than or equal to zero in %s on line %d bool(false) bool(false) diff --git a/ext/gmp/tests/032.phpt b/ext/gmp/tests/gmp_xor.phpt index 2b0d29a620..2b0d29a620 100644 --- a/ext/gmp/tests/032.phpt +++ b/ext/gmp/tests/gmp_xor.phpt diff --git a/ext/gmp/tests/overloading.phpt b/ext/gmp/tests/overloading.phpt index 0d8f5cfedb..3520f58bdc 100644 --- a/ext/gmp/tests/overloading.phpt +++ b/ext/gmp/tests/overloading.phpt @@ -16,6 +16,10 @@ var_dump($a - $b); var_dump($a - 17); var_dump(42 - $b); +var_dump($a * $b); +var_dump($a * 17); +var_dump(42 * $b); + var_dump($a / $b); var_dump($a / 17); var_dump(42 / $b); @@ -26,7 +30,9 @@ var_dump($a % 17); var_dump(42 % $b); var_dump($a % 0); -// sl, sr +var_dump($a ** $b); +var_dump($a ** 17); +var_dump(42 ** $b); var_dump($a | $b); var_dump($a | 17); @@ -47,6 +53,9 @@ var_dump(42 << $b); var_dump($a >> 2); var_dump(-$a >> 2); +var_dump($a << -1); +var_dump($a >> -1); + var_dump(~$a); var_dump(-$a); var_dump(+$a); @@ -83,9 +92,14 @@ var_dump(--$a); var_dump($a--); var_dump($a); -$x = gmp_init(3); -$y = gmp_init(2); -var_dump($x ** $y); +// Test operator that was not overloaded + +var_dump($a . $b); +var_dump($a . '17'); +var_dump('42' . $b); + +$a .= '17'; +var_dump($a); ?> --EXPECTF-- @@ -115,6 +129,18 @@ object(GMP)#%d (1) { } object(GMP)#%d (1) { ["num"]=> + string(3) "714" +} +object(GMP)#%d (1) { + ["num"]=> + string(3) "714" +} +object(GMP)#%d (1) { + ["num"]=> + string(3) "714" +} +object(GMP)#%d (1) { + ["num"]=> string(1) "2" } object(GMP)#%d (1) { @@ -145,6 +171,18 @@ Warning: main(): Zero operand not allowed in %s on line %d bool(false) object(GMP)#%d (1) { ["num"]=> + string(28) "3937657486715347520027492352" +} +object(GMP)#%d (1) { + ["num"]=> + string(28) "3937657486715347520027492352" +} +object(GMP)#%d (1) { + ["num"]=> + string(28) "3937657486715347520027492352" +} +object(GMP)#%d (1) { + ["num"]=> string(2) "59" } object(GMP)#%d (1) { @@ -199,6 +237,12 @@ object(GMP)#%d (1) { ["num"]=> string(3) "-11" } + +Warning: main(): Shift cannot be negative in %s on line %d +bool(false) + +Warning: main(): Shift cannot be negative in %s on line %d +bool(false) object(GMP)#%d (1) { ["num"]=> string(3) "-43" @@ -260,7 +304,7 @@ object(GMP)#%d (1) { ["num"]=> string(2) "42" } -object(GMP)#%d (1) { - ["num"]=> - string(1) "9" -} +string(4) "4217" +string(4) "4217" +string(4) "4217" +string(4) "4217" diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index 3a4ed748e3..aea4265376 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -195,15 +195,22 @@ static char *sapi_lsapi_getenv( char * name, size_t name_len TSRMLS_DC ) /* }}} */ -/* + + static int add_variable( const char * pKey, int keyLen, const char * pValue, int valLen, void * arg ) { - php_register_variable_safe((char *)pKey, (char *)pValue, valLen, (zval *)arg TSRMLS_CC); - return 1; + int filter_arg = (arg == PG(http_globals)[TRACK_VARS_ENV])?PARSE_ENV:PARSE_SERVER; + char * new_val = (char *) pValue; + unsigned int new_val_len; + + if (sapi_module.input_filter(filter_arg, (char *)pKey, &new_val, valLen, &new_val_len TSRMLS_CC)) { + php_register_variable_safe((char *)pKey, new_val, new_val_len, (zval *)arg ); + } + return 1; } -*/ +/* static int add_variable( const char * pKey, int keyLen, const char * pValue, int valLen, void * arg ) { @@ -222,6 +229,55 @@ static int add_variable( const char * pKey, int keyLen, const char * pValue, int #endif return 1; } +*/ + +static void litespeed_php_import_environment_variables(zval *array_ptr TSRMLS_DC) +{ + char buf[128]; + char **env, *p, *t = buf; + size_t alloc_size = sizeof(buf); + unsigned long nlen; /* ptrdiff_t is not portable */ + + if (PG(http_globals)[TRACK_VARS_ENV] && + array_ptr != PG(http_globals)[TRACK_VARS_ENV] && + Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY && + zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV])) > 0 + ) { + zval_dtor(array_ptr); + *array_ptr = *PG(http_globals)[TRACK_VARS_ENV]; + INIT_PZVAL(array_ptr); + zval_copy_ctor(array_ptr); + return; + } else if (PG(http_globals)[TRACK_VARS_SERVER] && + array_ptr != PG(http_globals)[TRACK_VARS_SERVER] && + Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY && + zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) > 0 + ) { + zval_dtor(array_ptr); + *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER]; + INIT_PZVAL(array_ptr); + zval_copy_ctor(array_ptr); + return; + } + + for (env = environ; env != NULL && *env != NULL; env++) { + p = strchr(*env, '='); + if (!p) { /* malformed entry? */ + continue; + } + nlen = p - *env; + if (nlen >= alloc_size) { + alloc_size = nlen + 64; + t = (t == buf ? emalloc(alloc_size): erealloc(t, alloc_size)); + } + memcpy(t, *env, nlen); + t[nlen] = '\0'; + add_variable(t, nlen, p + 1, strlen( p + 1 ), array_ptr TSRMLS_CC); + } + if (t != buf && t != NULL) { + efree(t); + } +} #if ((PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || PHP_MAJOR_VERSION < 5) @@ -268,7 +324,7 @@ static void sapi_lsapi_register_variables(zval *track_vars_array TSRMLS_DC) add_variable_magic_quote("PHP_SELF", 8, php_self, strlen( php_self ), track_vars_array ); } #endif - php_import_environment_variables(track_vars_array TSRMLS_CC); + litespeed_php_import_environment_variables(track_vars_array TSRMLS_CC); } else { php_import_environment_variables(track_vars_array TSRMLS_CC); @@ -370,7 +426,7 @@ static void sapi_lsapi_log_message(char *message TSRMLS_DC) static sapi_module_struct lsapi_sapi_module = { "litespeed", - "LiteSpeed V6.6", + "LiteSpeed V6.7", php_lsapi_startup, /* startup */ php_module_shutdown_wrapper, /* shutdown */ diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c index 786a3bd20b..aac823fc1c 100644 --- a/sapi/litespeed/lsapilib.c +++ b/sapi/litespeed/lsapilib.c @@ -1912,9 +1912,13 @@ int LSAPI_ForeachOrgHeader_r( LSAPI_Request * pReq, int ret; int count = 0; struct _headerInfo headers[512]; + if ( !pReq || !fn ) return -1; - + + if ( !pReq->m_pHeaderIndex ) + return 0; + for( i = 0; i < H_TRANSFER_ENCODING; ++i ) { if ( pReq->m_pHeaderIndex->m_headerOff[i] ) |