[libmath-prime-util-perl] 55/181: Allow string numbers to have a leading + sign

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:51:06 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 94dd05264e1d2640fc269768616eb015ca9fdfb9
Author: Dana Jacobsen <dana at acm.org>
Date:   Sat Dec 28 12:17:24 2013 -0800

    Allow string numbers to have a leading + sign
---
 lib/Math/Prime/Util/PP.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm
index f116c35..1f0b817 100644
--- a/lib/Math/Prime/Util/PP.pm
+++ b/lib/Math/Prime/Util/PP.pm
@@ -78,7 +78,7 @@ sub _validate_num {
   croak "Parameter must be defined" if !defined $n;
   return 0 if ref($n);
   croak "Parameter '$n' must be a positive integer"
-          if $n eq '' || $n =~ tr/0123456789//c;
+          if $n eq '' || ($n =~ tr/0123456789//c && $n !~ /^\+\d+/);
   croak "Parameter '$n' must be >= $min" if defined $min && $n < $min;
   croak "Parameter '$n' must be <= $max" if defined $max && $n > $max;
   return 0 unless $n < ~0 || int($n) eq ''.~0;
@@ -89,7 +89,7 @@ sub _validate_positive_integer {
   my($n, $min, $max) = @_;
   croak "Parameter must be defined" if !defined $n;
   croak "Parameter '$n' must be a positive integer"
-        if ref($n) ne 'Math::BigInt' && $n =~ tr/0123456789//c;
+     if ref($n) ne 'Math::BigInt' && ($n =~ tr/0123456789//c && $n !~ /^\+\d+/);
   croak "Parameter '$n' must be >= $min" if defined $min && $n < $min;
   croak "Parameter '$n' must be <= $max" if defined $max && $n > $max;
   $_[0] = Math::BigInt->new("$_[0]") unless ref($_[0]) eq 'Math::BigInt';

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