[libmath-prime-util-perl] 18/55: Fix forcomposite with endpoint past max prime
Partha P. Mukherjee
ppm-guest at moszumanska.debian.org
Thu May 21 18:53:40 UTC 2015
This is an automated email from the git hooks/post-receive script.
ppm-guest pushed a commit to annotated tag v0.41
in repository libmath-prime-util-perl.
commit c973a3911211d740a91c4b4d77df949fc3314f79
Author: Dana Jacobsen <dana at acm.org>
Date: Fri May 2 14:02:34 2014 -0700
Fix forcomposite with endpoint past max prime
---
XS.xs | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/XS.xs b/XS.xs
index e36026b..77d4dbd 100644
--- a/XS.xs
+++ b/XS.xs
@@ -1115,7 +1115,7 @@ forcomposites (SV* block, IN SV* svbeg, IN SV* svend = 0)
/* Find the two primes that bound their interval. */
/* If beg or end are >= max_prime, then this will die. */
prevprime = prev_prime(beg);
- nextprime = next_prime(end);
+ nextprime = (end >= MPU_MAX_PRIME) ? MPU_MAX_PRIME : next_prime(end);
ctx = start_segment_primes(beg, nextprime, &segment);
while (next_segment_primes(ctx, &seg_base, &seg_low, &seg_high)) {
START_DO_FOR_EACH_SIEVE_PRIME( segment, seg_low - seg_base, seg_high - seg_base ) {
@@ -1128,11 +1128,13 @@ forcomposites (SV* block, IN SV* svbeg, IN SV* svend = 0)
} END_DO_FOR_EACH_SIEVE_PRIME
}
end_segment_primes(ctx);
- MPUassert( nextprime >= end, "composite sieve skipped end numbers" );
+ beg = nextprime + 1;
+ if (beg != MPU_MAX_PRIME+1)
+ MPUassert( beg >= end, "composite sieve skipped end numbers" );
FIX_MULTICALL_REFCOUNT;
POP_MULTICALL;
}
- else
+ /* Fall through to handle the edge case */
#endif
if (beg <= end) {
beg = (beg <= 4) ? 3 : beg-1;
--
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