X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FCPANPLUS%2FDist%2FGentoo%2FVersion.pm;h=d76bcb47df96ef041db48f4deb8253c3dfbf60dc;hb=400c6076d23a0fa83acac09fc3351653c527cb65;hp=752fe97f7349c5c4eff71ed48d8e97cfc2772660;hpb=d77142c8216a27e216565391d32d2cf3f321f63c;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git diff --git a/lib/CPANPLUS/Dist/Gentoo/Version.pm b/lib/CPANPLUS/Dist/Gentoo/Version.pm index 752fe97..d76bcb4 100644 --- a/lib/CPANPLUS/Dist/Gentoo/Version.pm +++ b/lib/CPANPLUS/Dist/Gentoo/Version.pm @@ -9,11 +9,11 @@ CPANPLUS::Dist::Gentoo::Version - Gentoo version object. =head1 VERSION -Version 0.10 +Version 0.11 =cut -our $VERSION = '0.10'; +our $VERSION = '0.11'; =head1 DESCRIPTION @@ -126,12 +126,28 @@ sub _spaceship { my @a = @{ $v1->version }; my @b = @{ $v2->version }; - while (@a or @b) { - my $x = shift(@a) || 0; - my $y = shift(@b) || 0; + { + my $x = shift @a; + my $y = shift @b; my $c = $x <=> $y; return $c if $c; } + + while (@a and @b) { + my $x = shift @a; + my $y = shift @b; + my $c; + if ($x =~ /^0/ or $y =~ /^0/) { + s/0+\z// for $x, $y; + $c = $x cmp $y; + } else { + $c = $x <=> $y; + } + return $c if $c; + } + + return 1 if @a; + return -1 if @b; } { @@ -188,7 +204,7 @@ sub _stringify { =pod -This class provides overloaded methods for numerical comparison and strigification. +This class provides overloaded methods for numerical comparison and stringification. =head1 SEE ALSO