diff options
author | Daniel De Graaf <danieldg@inspircd.org> | 2010-04-03 10:10:11 -0500 |
---|---|---|
committer | Daniel De Graaf <danieldg@inspircd.org> | 2010-04-03 10:10:11 -0500 |
commit | e24ff3ffc6c3f3fc096b2efd8c5b60e28a562ffa (patch) | |
tree | ebe9514642a4b8ca49c3782cc761c47462c12c90 /modulemanager | |
parent | 3cf993500544c2157992650da2487bfa89be405d (diff) |
Fix version comparisons in modulemanager so that "core 2.0" will match 2.0.1
Diffstat (limited to 'modulemanager')
-rwxr-xr-x | modulemanager | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/modulemanager b/modulemanager index 41c2c872c..1d9f42b88 100755 --- a/modulemanager +++ b/modulemanager @@ -141,10 +141,9 @@ my %todo = %installed; sub ver_cmp { ($a,$b) = @_ if @_; - # string versions first, git IDs - if ($a =~ /[a-z0-9]{40}/ or $b =~ /[a-z0-9]{40}/) + if ($a !~ /^[0-9.]+$/ or $b !~ /^[0-9.]+$/) { - # it's a string version. compare them as such. + # not a valid version number, don't try to sort return $a ne $b; } @@ -152,7 +151,7 @@ sub ver_cmp { my @a = split /\./, $a; my @b = split /\./, $b; push @a, 0 while $#a < $#b; - push @b, 0 while $#b < $#a; + push @b, ($_[2] || 0) while $#b < $#a; for my $i (0..$#a) { my $d = $a[$i] <=> $b[$i]; return $d if $d; @@ -163,13 +162,13 @@ sub ver_cmp { sub ver_in_range { my($ver, $range) = @_; return 1 unless defined $range; + my($l,$h) = ($range, $range); if ($range =~ /(.*)-(.*)/) { - my($l,$h) = ($1,$2); - return 0 if $l && ver_cmp($ver, $l) < 0; - return 0 if $h && ver_cmp($ver, $h) > 0; - return 1; + ($l,$h) = ($1,$2); } - return !ver_cmp($ver, $range); + return 0 if $l && ver_cmp($ver, $l) < 0; + return 0 if $h && ver_cmp($ver, $h, 9999) > 0; + return 1; } sub find_mod_in_range { |