summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTels <nospam-abuse@bloodgate.com>2002-07-12 10:38:45 +0200
committerJarkko Hietaniemi <jhi@iki.fi>2002-07-12 12:39:00 +0000
commit739c8b3a364622b7992851a224b3e6424e7e3b03 (patch)
tree5042059f8c92a401e541f56fbdaec37e7a3429d4 /lib
parent698020e13f7d895852858e436ca60023dbfe6077 (diff)
downloadperl-739c8b3a364622b7992851a224b3e6424e7e3b03.tar.gz
[PATCH9 BigInt v1.60 fix for "\n"
Message-Id: <200207120634.g6C6YjG6742777@taku.hut.fi> p4raw-id: //depot/perl@17498
Diffstat (limited to 'lib')
-rw-r--r--lib/Math/BigInt.pm10
-rw-r--r--lib/Math/BigInt/t/bare_mbi.t2
-rw-r--r--lib/Math/BigInt/t/bigintpm.inc80
-rwxr-xr-xlib/Math/BigInt/t/bigintpm.t2
-rwxr-xr-xlib/Math/BigInt/t/sub_mbi.t2
5 files changed, 86 insertions, 10 deletions
diff --git a/lib/Math/BigInt.pm b/lib/Math/BigInt.pm
index 800a97f275..5a1385d519 100644
--- a/lib/Math/BigInt.pm
+++ b/lib/Math/BigInt.pm
@@ -18,6 +18,7 @@ package Math::BigInt;
my $class = "Math::BigInt";
require 5.005;
+# This is a patched v1.60, containing a fix for the "1234567890\n" bug
$VERSION = '1.60';
use Exporter;
@ISA = qw( Exporter );
@@ -406,7 +407,7 @@ sub new
my $self = bless {}, $class;
# shortcut for "normal" numbers
- if ((!ref $wanted) && ($wanted =~ /^([+-]?)[1-9][0-9]*$/))
+ if ((!ref $wanted) && ($wanted =~ /^([+-]?)[1-9][0-9]*\z/))
{
$self->{sign} = $1 || '+';
my $ref = \$wanted;
@@ -2523,7 +2524,7 @@ sub _split
$$x =~ s/\s+$//g; # strip white space at end
# shortcut, if nothing to split, return early
- if ($$x =~ /^[+-]?\d+$/)
+ if ($$x =~ /^[+-]?\d+\z/)
{
$$x =~ s/^([+-])0*([0-9])/$2/; my $sign = $1 || '+';
return (\$sign, $x, \'', \'', \0);
@@ -3896,11 +3897,6 @@ versions to a more sophisticated scheme):
=over 2
-=item Input with trailing newlines
-
-Input with trailing newlines is handled wrong (e.g. lead to corrupted numbers)
-in some cases, for instance "123\n" or "123456789\n".
-
=item Out of Memory!
Under Perl prior to 5.6.0 having an C<use Math::BigInt ':constant';> and
diff --git a/lib/Math/BigInt/t/bare_mbi.t b/lib/Math/BigInt/t/bare_mbi.t
index 8e53b63986..c725e5af55 100644
--- a/lib/Math/BigInt/t/bare_mbi.t
+++ b/lib/Math/BigInt/t/bare_mbi.t
@@ -26,7 +26,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 2392;
+ plan tests => 2552;
}
use Math::BigInt lib => 'BareCalc';
diff --git a/lib/Math/BigInt/t/bigintpm.inc b/lib/Math/BigInt/t/bigintpm.inc
index 7aa3627fbb..fa5b6f0de1 100644
--- a/lib/Math/BigInt/t/bigintpm.inc
+++ b/lib/Math/BigInt/t/bigintpm.inc
@@ -736,6 +736,86 @@ NaN:inf:
-inf:NaN:
NaN:-inf:
&bnorm
+-0\n:0
+-123\n:-123
+-1234\n:-1234
+-12345\n:-12345
+-123456\n:-123456
+-1234567\n:-1234567
+-12345678\n:-12345678
+-123456789\n:-123456789
+-1234567890\n:-1234567890
+-12345678901\n:-12345678901
+0\n:0
+123\n:123
+1234\n:1234
+12345\n:12345
+123456\n:123456
+1234567\n:1234567
+12345678\n:12345678
+123456789\n:123456789
+1234567890\n:1234567890
+12345678901\n:12345678901
+\n0:0
+\n123:123
+\n1234:1234
+\n12345:12345
+\n123456:123456
+\n1234567:1234567
+\n12345678:12345678
+\n123456789:123456789
+\n1234567890:1234567890
+\n12345678901:12345678901
+\n0\n:0
+\n123\n:123
+\n1234\n:1234
+\n12345\n:12345
+\n123456\n:123456
+\n1234567\n:1234567
+\n12345678\n:12345678
+\n123456789\n:123456789
+\n1234567890\n:1234567890
+\n12345678901\n:12345678901
+\t0\n:0
+\t123\n:123
+\t1234\n:1234
+\t12345\n:12345
+\t123456\n:123456
+\t1234567\n:1234567
+\t12345678\n:12345678
+\t123456789\n:123456789
+\t1234567890\n:1234567890
+\t12345678901\n:12345678901
+\n0\t:0
+\n123\t:123
+\n1234\t:1234
+\n12345\t:12345
+\n123456\t:123456
+\n1234567\t:1234567
+\n12345678\t:12345678
+\n123456789\t:123456789
+\n1234567890\t:1234567890
+\n12345678901\t:12345678901
+0\n\n:0
+123\n\n:123
+1234\n\n:1234
+12345\n\n:12345
+123456\n\n:123456
+1234567\n\n:1234567
+12345678\n\n:12345678
+123456789\n\n:123456789
+1234567890\n\n:1234567890
+12345678901\n\n:12345678901
+\n\n0:0
+\n\n123:123
+\n\n1234:1234
+\n\n12345:12345
+\n\n123456:123456
+\n\n1234567:1234567
+\n\n12345678:12345678
+\n\n123456789:123456789
+\n\n1234567890:1234567890
+\n\n12345678901:12345678901
123:123
# binary input
0babc:NaN
diff --git a/lib/Math/BigInt/t/bigintpm.t b/lib/Math/BigInt/t/bigintpm.t
index 2d315cc041..b4c4f111dd 100755
--- a/lib/Math/BigInt/t/bigintpm.t
+++ b/lib/Math/BigInt/t/bigintpm.t
@@ -10,7 +10,7 @@ BEGIN
my $location = $0; $location =~ s/bigintpm.t//;
unshift @INC, $location; # to locate the testing files
chdir 't' if -d 't';
- plan tests => 2392;
+ plan tests => 2552;
}
use Math::BigInt;
diff --git a/lib/Math/BigInt/t/sub_mbi.t b/lib/Math/BigInt/t/sub_mbi.t
index 0c0cfa6752..a68113d4f4 100755
--- a/lib/Math/BigInt/t/sub_mbi.t
+++ b/lib/Math/BigInt/t/sub_mbi.t
@@ -26,7 +26,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 2392
+ plan tests => 2552
+ 5; # +5 own tests
}