[libmath-prime-util-perl] 96/181: Work around RT 49569 (Math::BigInt::FastCalc)

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


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

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

commit 1de1b84039542eaf636804560f7c3d75891b0005
Author: Dana Jacobsen <dana at acm.org>
Date:   Wed Jan 1 23:42:22 2014 -0800

    Work around RT 49569 (Math::BigInt::FastCalc)
---
 Makefile.PL                             |  1 +
 XS.xs                                   |  6 +++++-
 lib/Math/Prime/Util/PrimalityProving.pm | 15 +++++++--------
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/Makefile.PL b/Makefile.PL
index 38d5757..f0ddf69 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -47,6 +47,7 @@ WriteMakefile1(
                       'base'             => 0,
                       'constant'         => 0,
                       'Config'           => 0,
+                      # 1.99 fixes the FastCalc SvUV bug, we work around it.
                       'Math::BigInt'     => '1.88',
                       'Math::BigFloat'   => '1.59',
                       'Bytes::Random::Secure' => '0.23',
diff --git a/XS.xs b/XS.xs
index e4e21d2..87547e4 100644
--- a/XS.xs
+++ b/XS.xs
@@ -36,10 +36,14 @@
   #define PSTRTOLL(str, end, base)  strtol (str, end, base)
 #endif
 
-/* Workaround perl 5.6 UVs and bigints in later */
 #if PERL_REVISION <= 5 && PERL_VERSION <= 6 && BITS_PER_WORD == 64
+ /* Workaround perl 5.6 UVs and bigints */
  #define my_svuv(sv)  PSTRTOULL(SvPV_nolen(sv), NULL, 10)
  #define my_sviv(sv)  PSTRTOLL(SvPV_nolen(sv), NULL, 10)
+#elif PERL_REVISION <= 5 && PERL_VERSION < 14 && BITS_PER_WORD == 64
+ /* Workaround RT 49569 in Math::BigInt::FastCalc (pre 5.14.0) */
+ #define my_svuv(sv) ( (!SvROK(sv)) ? SvUV(sv) : PSTRTOULL(SvPV_nolen(sv),NULL,10) )
+ #define my_sviv(sv) ( (!SvROK(sv)) ? SvIV(sv) : PSTRTOLL(SvPV_nolen(sv),NULL,10) )
 #else
  #define my_svuv(sv) SvUV(sv)
  #define my_sviv(sv) SvIV(sv)
diff --git a/lib/Math/Prime/Util/PrimalityProving.pm b/lib/Math/Prime/Util/PrimalityProving.pm
index 8946d0a..4d5dfb4 100644
--- a/lib/Math/Prime/Util/PrimalityProving.pm
+++ b/lib/Math/Prime/Util/PrimalityProving.pm
@@ -2,6 +2,7 @@ package Math::Prime::Util::PrimalityProving;
 use strict;
 use warnings;
 use Carp qw/carp croak confess/;
+use Math::BigInt try=>"GMP,Pari";
 use Math::Prime::Util qw/is_prob_prime is_strong_pseudoprime
                          is_provable_prime_with_cert
                          lucas_sequence
@@ -9,11 +10,6 @@ use Math::Prime::Util qw/is_prob_prime is_strong_pseudoprime
                          prime_get_config
                         /;
 
-if (!defined $Math::BigInt::VERSION) {
-  eval { require Math::BigInt;   Math::BigInt->import(try=>'GMP,Pari'); 1; }
-  or do { croak "Cannot load Math::BigInt"; };
-}
-
 BEGIN {
   $Math::Prime::Util::PrimalityProving::AUTHORITY = 'cpan:DANAJ';
   $Math::Prime::Util::PrimalityProving::VERSION = '0.35';
@@ -378,12 +374,12 @@ sub convert_array_cert_to_string {
 ###############################################################################
 
 sub _primality_error ($) {  ## no critic qw(ProhibitSubroutinePrototypes)
-  print "primality fail: $_[0]" if prime_get_config->{'verbose'};
+  print "primality fail: $_[0]\n" if prime_get_config->{'verbose'};
   return;  # error in certificate
 }
 
 sub _pfail ($) {            ## no critic qw(ProhibitSubroutinePrototypes)
-  print "primality fail: $_[0]" if prime_get_config->{'verbose'};
+  print "primality fail: $_[0]\n" if prime_get_config->{'verbose'};
   return;  # Failed a condition
 }
 
@@ -788,7 +784,10 @@ sub verify_cert {
     if ( ($cert_type eq 'PRIMO' && $line =~ /^\[Candidate\]/) || ($cert_type eq 'MPU' && $line =~ /^Proof for:/) ) {
       return _primality_error "Certificate with multiple N values" if defined $N;
       ($N) = _read_vars($lines, 'Proof for', qw/N/);
-      return 0 unless is_prob_prime($N);
+      if (!is_prob_prime($N)) {
+        _pfail "N '$N' does not look prime.";
+        return 0;
+      }
       next;
     }
     if ($line =~ /^Base (\d+)/) {

-- 
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