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 ae11792b3ac9cda84189f6390a95c6e538467191
Author: Dana Jacobsen <d...@acm.org>
Date:   Thu May 23 23:03:23 2013 -0700

    ranged moebius was depending on char being signed.  Fix.  Thanks Debian 
testers.
---
 Changes |  4 ++++
 XS.xs   |  2 +-
 util.c  | 12 ++++++------
 util.h  |  2 +-
 4 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/Changes b/Changes
index 9c4b0e3..80e2fee 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for Perl extension Math::Prime::Util.
 
+0.29 xx May 2013
+
+    - Fix a signed vs. unsigned char issue in ranged moebius.
+
 0.28 23 May 2013
 
     - An optimization to nth_prime caused occasional threaded Win32 faults.
diff --git a/XS.xs b/XS.xs
index bc01288..3422caa 100644
--- a/XS.xs
+++ b/XS.xs
@@ -546,7 +546,7 @@ _XS_moebius(IN UV lo, IN UV hi = 0)
     UV i;
   PPCODE:
     if (hi != lo && hi != 0) {   /* mobius in a range */
-      char* mu = _moebius_range(lo, hi);
+      signed char* mu = _moebius_range(lo, hi);
       MPUassert( mu != 0, "_moebius_range returned 0" );
       EXTEND(SP, hi-lo+1);
       for (i = lo; i <= hi; i++)
diff --git a/util.c b/util.c
index 48d6ce0..3507eaa 100644
--- a/util.c
+++ b/util.c
@@ -739,14 +739,14 @@ UV _XS_nth_prime(UV n)
 #define PGTLO(p,lo)  ((p) >= lo) ? (p) : ((p)*(lo/(p)) + ((lo%(p))?(p):0))
 #define P2GTLO(pinit, p, lo) \
    ((pinit) >= lo) ? (pinit) : ((p)*(lo/(p)) + ((lo%(p))?(p):0))
-char* _moebius_range(UV lo, UV hi)
+signed char* _moebius_range(UV lo, UV hi)
 {
-  char* mu;
+  signed char* mu;
   UV i;
   UV sqrtn = isqrt(hi);
 #if 0
   /* Simple char method.  Needs way too many primes. */
-  New(0, mu, hi-lo+1, char);
+  New(0, mu, hi-lo+1, signed char);
   if (mu == 0)
     croak("Could not get memory for %"UVuf" moebius results\n", hi-lo+1);
   memset(mu, 1, hi-lo+1);
@@ -780,7 +780,7 @@ char* _moebius_range(UV lo, UV hi)
     for (i = PGTLO(p, lo); i <= hi; i += p)
       A[i-lo] *= -(IV)p;
   } END_DO_FOR_EACH_PRIME
-  New(0, mu, hi-lo+1, char);
+  New(0, mu, hi-lo+1, signed char);
   if (mu == 0)
     croak("Could not get memory for %"UVuf" moebius results\n", hi-lo+1);
   memset(mu, 0, hi-lo+1);
@@ -801,7 +801,7 @@ char* _moebius_range(UV lo, UV hi)
   unsigned char logp;
   UV nextlog;
 
-  Newz(0, mu, hi-lo+1, char);
+  Newz(0, mu, hi-lo+1, signed char);
   if (mu == 0)
     croak("Could not get memory for %"UVuf" moebius results\n", hi-lo+1);
   A = (unsigned char*) mu;
@@ -883,7 +883,7 @@ IV _XS_mertens(UV n) {
    * This implementation uses their lemma 2.1 directly, so is n^1/2.
    */
   UV u, i, m, nmk;
-  char* mu;
+  signed char* mu;
   IV* M;
   IV sum;
 
diff --git a/util.h b/util.h
index 36ba169..4194879 100644
--- a/util.h
+++ b/util.h
@@ -15,7 +15,7 @@ extern UV  _XS_prev_prime(UV x);
 extern UV  _XS_prime_count(UV low, UV high);
 extern UV  _XS_nth_prime(UV x);
 
-extern char*  _moebius_range(UV low, UV high);
+extern signed char* _moebius_range(UV low, UV high);
 extern UV*    _totient_range(UV low, UV high);
 extern IV     _XS_mertens(UV n);
 extern double _XS_chebyshev_theta(UV n);

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