X-Git-Url: https://git.deb.at/?p=deb%2Fpackages.git;a=blobdiff_plain;f=lib%2FDeb%2FVersions.pm;h=d8d8282a3fcd39d3324dc5536632ac203d310668;hp=984cbfb0b5ddb1775f2cc05055db9d2e6b38ab67;hb=d833a5eed5296d1a24c35e8f0802f8291037198d;hpb=5ca21f1ba07a6b559395bec8d6bc1e528eb238d1;ds=sidebyside diff --git a/lib/Deb/Versions.pm b/lib/Deb/Versions.pm index 984cbfb..d8d8282 100644 --- a/lib/Deb/Versions.pm +++ b/lib/Deb/Versions.pm @@ -1,6 +1,5 @@ # # Deb::Versions -# $Id$ # # Copyright 2003, 2004 Frank Lichtenheld # @@ -16,7 +15,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # =head1 NAME @@ -111,7 +110,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,13 +137,13 @@ 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 + $n1 += 256 if $n1 && $n1 < 65; # letters sort earlier than non-letters $n1 = -1 if $n1 == 126; # '~' sorts earlier than everything else - $n2 += 256 if $n2 < 65; + $n2 += 256 if $n2 && $n2 < 65; $n2 = -1 if $n2 == 126; if ( my $r = ($n1 <=> $n2) ) { return $r; @@ -154,12 +153,14 @@ sub _lcmp { } 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 ); + etch etch-m68k testing testing-proposed-updates lenny + sid unstable experimental + warty hoary breezy breezy dapper edgy feisty gutsy ); +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 +183,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__