X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=lib%2FDeb%2FVersions.pm;h=5f3b1db7b8062719c0c603720b2c28f9762c8835;hb=708b1364be58c9b921cc3838d7ed5f5b48959d78;hp=984cbfb0b5ddb1775f2cc05055db9d2e6b38ab67;hpb=5ca21f1ba07a6b559395bec8d6bc1e528eb238d1;p=deb%2Fpackages.git diff --git a/lib/Deb/Versions.pm b/lib/Deb/Versions.pm index 984cbfb..5f3b1db 100644 --- a/lib/Deb/Versions.pm +++ b/lib/Deb/Versions.pm @@ -111,7 +111,7 @@ sub _cmp_part { my ( $v1, $v2 ) = @_; my $r; - while ( $v1 && $v2 ) { + while ( $v1 || $v2 ) { $v1 =~ s/^(\D*)//o; my $sp1 = $1; $v2 =~ s/^(\D*)//o; @@ -138,8 +138,8 @@ sub _cmp_part { sub _lcmp { my ( $v1, $v2 ) = @_; - - for ( my $i = 0; $i < length( $v1 ); $i++ ) { + + for ( my $i = 0; $i <= length( $v1 ); $i++ ) { my ( $n1, $n2 ) = ( ord( substr( $v1, $i, 1 ) ), ord( substr( $v2, $i, 1 ) ) ); $n1 += 256 if $n1 < 65; # letters sort earlier than non-letters @@ -157,9 +157,11 @@ our @SUITES_SORT = qw( woody oldstable sarge stable stable-proposed-updates etch testing testing-proposed-updates sid unstable experimental warty hoary hoary-backports breezy breezy-backports dapper ); -our @ARCHIVE_SORT = qw( security updates volatile backports ); +our @ARCHIVE_SORT = qw( non-US security updates volatile backports ); +our @PRIORITY_SORT = qw( required important standard optional extra ); my $i = 1000; our %suites_sort = map { $_ => ($i-=10) } @SUITES_SORT; +our %priority_sort = map { $_ => $i-- } @PRIORITY_SORT; $i = 0; our %archive_sort = map { $_ => $i++ } @ARCHIVE_SORT; @@ -182,6 +184,14 @@ sub suites_sort { return sort { suites_cmp( $b, $a ) } @_; } +sub priority_cmp { + return ($priority_sort{$_[0]} <=> $priority_sort{$_[1]}); +} + +sub priority_sort { + return sort { priority_cmp( $b, $a ) } @_; +} + 1; __END__