In perl.git, the branch smoke-me/tonyc/post-5.22 has been updated <http://perl5.git.perl.org/perl.git/commitdiff/8b052325fdd6dbb094868aeac9cfa5258dd015d5?hp=0e03340a24726249d48f7cd8c5b1e6348f61d3c1>
- Log ----------------------------------------------------------------- commit 8b052325fdd6dbb094868aeac9cfa5258dd015d5 Author: Niko Tyni <[email protected]> Date: Sat Apr 18 18:59:07 2015 +0300 Fix quote() function to escape backslashes but not minus signs The delimiter character isn't special in character square brackets, and neither is the backslash. So '\-\' means just a range of backslash to backslash, and the minus sign isn't included at all. Substitution tested with GNU Solaris 9 sed programs. Originally noticed by Kristoffer Grundstr?m. Bug-Debian: https://bugs.debian.org/754057 M Makefile.SH commit ee3ac3f4306152ec51a99887699f05d1ce28e749 Author: Peter John Acklam <[email protected]> Date: Fri Apr 17 21:28:37 2015 +0200 Correct Math::BigInt -> new() for non-integer input. The documentation in Math::BigInt says about input values that "Non-integer values result in NaN." The actual behaviour doesn't comply with this. - All input values in the range (-1,1) written as a decimal number, e.g., -0.75 and 0.5, now return NaN, not 0. - Input values with a large (absolute value) negative exponent, e.g., 1e-9999999, now return NaN. The former behaviour was to die with the message "Quantifier in {,} bigger than 32766 in regex; marked by ..." - This patch fixes CPAN RT #61887 and CPAN RT #63038. M dist/Math-BigInt/lib/Math/BigInt.pm M dist/Math-BigInt/t/bigintpm.inc ----------------------------------------------------------------------- Summary of changes: Makefile.SH | 2 +- dist/Math-BigInt/lib/Math/BigInt.pm | 16 +++++++++++----- dist/Math-BigInt/t/bigintpm.inc | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Makefile.SH b/Makefile.SH index 4a7a357..c2585e3 100755 --- a/Makefile.SH +++ b/Makefile.SH @@ -5,7 +5,7 @@ quote() { case "$1" in '') echo "''" ;; - *) echo "$1" | sed 's/\([^a-zA-Z0-9.:_\-\/]\)/\\\1/g' ;; + *) echo "$1" | sed 's/\([^a-zA-Z0-9.:_/-]\)/\\\1/g' ;; esac } diff --git a/dist/Math-BigInt/lib/Math/BigInt.pm b/dist/Math-BigInt/lib/Math/BigInt.pm index 2381c26..d990272 100644 --- a/dist/Math-BigInt/lib/Math/BigInt.pm +++ b/dist/Math-BigInt/lib/Math/BigInt.pm @@ -626,9 +626,13 @@ sub new elsif ($e < 0) { # xE-y, and empty mfv - #print "xE-y\n"; - $e = abs($e); - if ($$miv !~ s/0{$e}$//) # can strip so many zero's? + # Split the mantissa at the decimal point. E.g., if + # $$miv = 12345 and $e = -2, then $frac = 45 and $$miv = 123. + + my $frac = substr($$miv, $e); # $frac is fraction part + substr($$miv, $e) = ""; # $$miv is now integer part + + if ($frac =~ /[^0]/) { if ($_trap_nan) { @@ -640,8 +644,10 @@ sub new } } } - $self->{sign} = '+' if $$miv eq '0'; # normalize -0 => +0 - $self->{value} = $CALC->_new($$miv) if $self->{sign} =~ /^[+-]$/; + unless ($self->{sign} eq $nan) { + $self->{sign} = '+' if $$miv eq '0'; # normalize -0 => +0 + $self->{value} = $CALC->_new($$miv) if $self->{sign} =~ /^[+-]$/; + } # if any of the globals is set, use them to round and store them inside $self # do not round for new($x,undef,undef) since that is used by MBF to signal # no rounding diff --git a/dist/Math-BigInt/t/bigintpm.inc b/dist/Math-BigInt/t/bigintpm.inc index 1481502..08a98ac 100644 --- a/dist/Math-BigInt/t/bigintpm.inc +++ b/dist/Math-BigInt/t/bigintpm.inc @@ -1091,6 +1091,8 @@ E23:NaN -1010E-2:NaN -1.01E+1:NaN -1.01E-1:NaN +1E-999999:NaN +0.5:NaN &bnan 1:NaN 2:NaN @@ -2407,8 +2409,6 @@ inf:-inf:NaN 15241:2:123 144:2:12 12:2:3 -0.49:2:0 -0.0049:2:0 # invalid ones 1:NaN:NaN -1:NaN:NaN -- Perl5 Master Repository
