From 708b1364be58c9b921cc3838d7ed5f5b48959d78 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Sat, 2 Jun 2007 18:01:29 +0200 Subject: [PATCH] Deb/Versions.pm: Fix handling of ~ vs. empty string ~ sorts even before the empty string, so we can't just abort if one of the revisions is shorter than the other since it can still sort later. --- lib/Deb/Versions.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Deb/Versions.pm b/lib/Deb/Versions.pm index 4f3b320..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 -- 2.39.2