[libmath-prime-util-perl] 09/11: Fix issue with Math::BigInt::GMP on 32-bit Win32

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:46:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.15
in repository libmath-prime-util-perl.

commit d588c121e9033f0fccc992b6adfa886e06fae88c
Author: Dana Jacobsen <dana at acm.org>
Date:   Sun Dec 9 16:05:28 2012 -0800

    Fix issue with Math::BigInt::GMP on 32-bit Win32
---
 lib/Math/Prime/Util.pm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index 87399cb..eaad7ef 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -97,6 +97,10 @@ BEGIN {
 
   use Config;
   $_Config{'system_randbits'} = $Config{'randbits'};
+  # We should probably croak if it's too low.
+  $_Config{'system_randbits'} = 15 if $_Config{'system_randbits'} < 15;
+  # Keep things in integer range.
+  $_Config{'system_randbits'} = $_Config{'maxbits'} if $_Config{'system_randbits'} > $_Config{'maxbits'};
   no Config;
 
 }
@@ -595,9 +599,10 @@ sub primes {
     my $rand_part_size = 1 << 31;  # Max size we want to use.
     if (ref($oddrange) eq 'Math::BigInt') {
       # Go to some trouble here because some systems are wonky, such as
-      # giving us +a/+b = -r.
+      # giving us +a/+b = -r.  Also note the quotes for the bigint argument.
+      # Without that, Math::BigInt::GMP on 32-bit Win32 will return garbage.
       my($nbins, $rem);
-      ($nbins, $rem) = $oddrange->copy->bdiv( $rand_part_size );
+      ($nbins, $rem) = $oddrange->copy->bdiv( "$rand_part_size" );
       $nbins++ if $rem > 0;
       ($binsize,$rem) = $oddrange->copy->bdiv($nbins);
       $binsize++ if $rem > 0;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git



More information about the Pkg-perl-cvs-commits mailing list