diff --git a/Changes b/Changes index aa631bf..e8a1705 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for Perl extension NetAddr::IP +4.055 Fri Oct 28 11:41:22 PDT 2011 + in Lite.pm v1.38 + patch for bug 71869, issues with Math::BigInt varients + 4.054 Thu Oct 27 12:48:55 PDT 2011 In Lite.pm v1.37, remove Calc.pm add detection of early Math::Bigint object structure diff --git a/IP.pm b/IP.pm index e1f7264..b05f391 100644 --- a/IP.pm +++ b/IP.pm @@ -4,7 +4,7 @@ use strict; #use diagnostics; -use NetAddr::IP::Lite 1.37 qw(Zero Zeros Ones V4mask V4net); +use NetAddr::IP::Lite 1.38 qw(Zero Zeros Ones V4mask V4net); use NetAddr::IP::Util 1.43 qw( sub128 inet_aton @@ -35,7 +35,7 @@ @ISA = qw(Exporter NetAddr::IP::Lite); -$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.54 $ =~ /\d+/g) }; +$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.55 $ =~ /\d+/g) }; =pod diff --git a/Lite/Changes b/Lite/Changes index c1e72e8..ffd88e7 100644 --- a/Lite/Changes +++ b/Lite/Changes @@ -1,5 +1,8 @@ Revision history for Perl extension NetAddr::IP::Lite +1.38 Fri Oct 28 11:41:22 PDT 2011 + patch for bug 71869, issues with Math::BigInt varients + 1.37 Thu Oct 27 12:48:55 PDT 2011 add detection of early Math::Bigint 0.01 object structures circa perl 5.6.1 diff --git a/Lite/Lite.pm b/Lite/Lite.pm index 7c46956..75b97fe 100644 --- a/Lite/Lite.pm +++ b/Lite/Lite.pm @@ -31,7 +31,7 @@ use vars qw(@ISA @EXPORT_OK $VERSION $Accept_Binary_IP $Old_nth $AUTOLOAD *Zero); -$VERSION = do { my @r = (q$Revision: 1.37 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.38 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; require Exporter; @@ -717,16 +717,6 @@ return sprintf("%d.%d.%d.%d",$1,$2,$3,$4); } -# function to stringify various flavors of Math::BigInt objects -# tests to see if the object is a hash or a signed scalar -# -sub retMBIstring { - local *MBI = $_[0]; - return (defined *MBI{HASH}) # recent version ? - ? join('',reverse @{$_[0]->{value}}) - : do { ${$_[0]} =~ /(\d+)/; $1 }; -} - sub _xnew($$;$$) { my $noctal = 0; my $isV6 = shift; @@ -739,7 +729,7 @@ my $ip = shift; $ip = 'default' unless defined $ip; - $ip = retMBIstring($ip) # treat as big bcd string + $ip = _retMBIstring($ip) # treat as big bcd string if ref $ip && ref $ip eq 'Math::BigInt'; # can /CIDR notation my $hasmask = 1; my($mask,$tmp); @@ -813,7 +803,7 @@ # if either of the above conditions is true, $try contains the NetAddr 128 bit address # checkfor Math::BigInt mask - $mask = retMBIstring($mask) # treat as big bcd string + $mask = _retMBIstring($mask) # treat as big bcd string if ref $mask && ref $mask eq 'Math::BigInt'; # MASK to lower case AFTER ref test for Math::BigInt, 'lc' strips blessing @@ -1207,38 +1197,63 @@ =cut -# as of this writing there are three known flavors of Math::BigInt -# v0.01 MBI::new returns a scalar ref -# v1.?? - 1.69 CALC::_new takes a reference to a scalar, returns an array, MBI returns a hash ref -# v1.70 and up CALC::_new takes a scalar, returns and array, MBI returns a hash ref - my $biloaded; +my $bi2strng; my $no_mbi_emu = 1; # function to force into test development mode # sub _force_bi_emu { undef $biloaded; + undef $bi2strng; $no_mbi_emu = 0; - print STDERR "\n\n\tWARNING: test development mode, this + print STDERR "\n\n\tWARNING: test development mode, this \tmessage SHOULD NEVER BE SEEN IN PRODUCTION! set my \$no_mbi_emu = 1 in t/bigint.t to remove this warning\n\n"; } -# from bi string like Math::BigInt 0.01 +# function to stringify various flavors of Math::BigInt objects +# tests to see if the object is a hash or a signed scalar + +sub _bi_stfy { + "$_[0]" =~ /(\d+)/; # stringify and remove '+' if present + $1; +} + +sub _fakebi2strg { + ${$_[0]} =~ /(\d+)/; + $1; +} + +# fake new from bi string Math::BigInt 0.01 # sub _bi_fake { bless \('+'. $_[1]), 'Math::BigInt'; } -sub _biRef { - unless ($biloaded) { # load Math::BigInt on demand - if (eval {$no_mbi_emu && require Math::BigInt}) { # any version should work, three known - $biloaded = \&Math::BigInt::new; - } else { - $biloaded = \&_bi_fake; - } +# as of this writing there are three known flavors of Math::BigInt +# v0.01 MBI::new returns a scalar ref +# v1.?? - 1.69 CALC::_new takes a reference to a scalar, returns an array, MBI returns a hash ref +# v1.70 and up CALC::_new takes a scalar, returns and array, MBI returns a hash ref + +sub _loadMBI { # load Math::BigInt on demand + if (eval {$no_mbi_emu && require Math::BigInt}) { # any version should work, three known + import Math::BigInt; + $biloaded = \&Math::BigInt::new; + $bi2strng = \&_bi_stfy; + } else { + $biloaded = \&_bi_fake; + $bi2strng = \&_fakebi2strg; } +} + +sub _retMBIstring { + _loadMBI unless $biloaded; # load Math::BigInt on demand + $bi2strng->(@_); +} + +sub _biRef { + _loadMBI unless $biloaded; # load Math::BigInt on demand $biloaded->('Math::BigInt',$_[0]); } diff --git a/META.yml b/META.yml index 8457fdd..5ef4322 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- #YAML:1.0 name: NetAddr-IP -version: 4.054 +version: 4.055 abstract: Manages IPv4 and IPv6 addresses and subnets license: ~ author: