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

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

commit a8d928e44a1e60192977e54c75d8c62d770a8ce5
Author: Dana Jacobsen <d...@acm.org>
Date:   Thu May 30 23:50:03 2013 -0700

    Workaround for MSVC compiler
---
 Changes |  2 ++
 XS.xs   | 25 ++++++++++++++++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/Changes b/Changes
index aa6c381..a798d32 100644
--- a/Changes
+++ b/Changes
@@ -17,6 +17,8 @@ Revision history for Perl extension Math::Prime::Util.
       Math::MPFR.  Switch to Li+correction for large values if Math::MPFR is
       not available.
 
+    - Workaround for MSVC compiler.
+
     - Added:
         is_pseudoprime (Fermat probable prime test)
         is_lucas_pseudoprime (standard Lucas-Selfridge test)
diff --git a/XS.xs b/XS.xs
index 6b959f8..8f32f45 100644
--- a/XS.xs
+++ b/XS.xs
@@ -325,7 +325,7 @@ erat_primes(IN UV low, IN UV high)
     RETVAL
 
 
-#define SIMPLE_FACTOR(func, n, ...) \
+#define SIMPLE_FACTOR(func, n, arg1) \
     if (n <= 1) { \
       XPUSHs(sv_2mortal(newSVuv( n ))); \
     } else { \
@@ -337,7 +337,26 @@ erat_primes(IN UV low, IN UV high)
       else { \
         UV factors[MPU_MAX_FACTORS+1]; \
         int i, nfactors; \
-        nfactors = func(n, factors, ## __VA_ARGS__); \
+        nfactors = func(n, factors, arg1); \
+        for (i = 0; i < nfactors; i++) { \
+          XPUSHs(sv_2mortal(newSVuv( factors[i] ))); \
+        } \
+      } \
+    }
+#define SIMPLE_FACTOR_2ARG(func, n, arg1, arg2) \
+    /* Stupid MSVC won't bring its C compiler out of the 1980s. */ \
+    if (n <= 1) { \
+      XPUSHs(sv_2mortal(newSVuv( n ))); \
+    } else { \
+      while ( (n% 2) == 0 ) {  n /=  2;  XPUSHs(sv_2mortal(newSVuv( 2 ))); } \
+      while ( (n% 3) == 0 ) {  n /=  3;  XPUSHs(sv_2mortal(newSVuv( 3 ))); } \
+      while ( (n% 5) == 0 ) {  n /=  5;  XPUSHs(sv_2mortal(newSVuv( 5 ))); } \
+      if (n == 1) {  /* done */ } \
+      else if (_XS_is_prime(n)) { XPUSHs(sv_2mortal(newSVuv( n ))); } \
+      else { \
+        UV factors[MPU_MAX_FACTORS+1]; \
+        int i, nfactors; \
+        nfactors = func(n, factors, arg1, arg2); \
         for (i = 0; i < nfactors; i++) { \
           XPUSHs(sv_2mortal(newSVuv( factors[i] ))); \
         } \
@@ -396,7 +415,7 @@ pminus1_factor(IN UV n, IN UV B1 = 1*1024*1024, IN UV B2 = 
0)
   PPCODE:
     if (B2 == 0)
       B2 = 10*B1;
-    SIMPLE_FACTOR(pminus1_factor, n, B1, B2);
+    SIMPLE_FACTOR_2ARG(pminus1_factor, n, B1, B2);
 
 int
 _XS_is_pseudoprime(IN UV n, IN UV a)

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

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to