mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-28 12:10:59 +00:00
BigInteger: revamp base-10 regex
new Math_BigInteger('-09') gave 0 back as a number in GMP mode
This commit is contained in:
parent
994c2c6c79
commit
4e06ab52dd
@ -413,7 +413,10 @@ class Math_BigInteger {
|
||||
break;
|
||||
case 10:
|
||||
case -10:
|
||||
$x = preg_replace('#^(-?[0-9]*).*#', '$1', $x);
|
||||
// (?<!^)(?:-).*: find any -'s that aren't at the beginning and then any characters that follow that
|
||||
// (?<=^|-)0*: find any 0's that are preceeded by the start of the string or by a - (ie. octals)
|
||||
// [^-0-9].*: find any non-numeric characters and then any characters that follow that
|
||||
$x = preg_replace('#(?<!^)(?:-).*|(?<=^|-)0*|[^-0-9].*#', '', $x);
|
||||
|
||||
switch ( MATH_BIGINTEGER_MODE ) {
|
||||
case MATH_BIGINTEGER_MODE_GMP:
|
||||
|
Loading…
Reference in New Issue
Block a user