The following commit has been merged in the master branch:
commit 00a9e0039e41ae52d414a9605af5eca070175f28
Author: Raphaël Hertzog <[email protected]>
Date: Mon Oct 5 21:30:41 2009 +0200
Dpkg::Version: rename some functions and constants
version_compare_op() becomes version_compare_relation().
version_normalize_cmp_op() becomes version_normalize_relation().
The CMP_OP_* constants become REL_*.
Update all scripts and modules accordingly.
diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm
index 2fd5813..661a60e 100644
--- a/scripts/Dpkg/Changelog.pm
+++ b/scripts/Dpkg/Changelog.pm
@@ -257,7 +257,7 @@ sub __sanity_check_range {
warning(_g("'%s' option specifies non-existing version"), "since");
warning(_g("use newest entry that is smaller than the one specified"));
foreach my $v (@versions) {
- if (version_compare_op($v, CMP_OP_LT, $$since)) {
+ if (version_compare_relation($v, REL_LT, $$since)) {
$$since = $v;
last;
}
@@ -274,7 +274,7 @@ sub __sanity_check_range {
warning(_g("use oldest entry that is bigger than the one specified"));
my $oldest;
foreach my $v (@versions) {
- if (version_compare_op($v, CMP_OP_GT, $$from)) {
+ if (version_compare_relation($v, REL_GT, $$from)) {
$oldest = $v;
}
}
@@ -290,7 +290,7 @@ sub __sanity_check_range {
warning(_g("use oldest entry that is bigger than the one specified"));
my $oldest;
foreach my $v (@versions) {
- if (version_compare_op($v, CMP_OP_GT, $$until)) {
+ if (version_compare_relation($v, REL_GT, $$until)) {
$oldest = $v;
}
}
@@ -305,7 +305,7 @@ sub __sanity_check_range {
warning(_g("'%s' option specifies non-existing version"), "to");
warning(_g("use newest entry that is smaller than the one specified"));
foreach my $v (@versions) {
- if (version_compare_op($v, CMP_OP_LT, $$to)) {
+ if (version_compare_relation($v, REL_LT, $$to)) {
$$to = $v;
last;
}
diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm
index 38a697b..69b1cc6 100644
--- a/scripts/Dpkg/Deps.pm
+++ b/scripts/Dpkg/Deps.pm
@@ -518,7 +518,7 @@ sub parse {
\s*$ # trailing spaces at end
/x;
$self->{package} = $1;
- $self->{relation} = version_normalize_cmp_op($2) if defined($2);
+ $self->{relation} = version_normalize_relation($2) if defined($2);
if (defined($3)) {
$self->{version} = Dpkg::Version->new($3) || $3;
}
@@ -664,7 +664,8 @@ sub get_evaluation {
return 0;
} else {
if (defined($param)) {
- if (version_compare_op($param, $self->{relation},
$self->{version})) {
+ if (version_compare_relation($param, $self->{relation},
+ $self->{version})) {
return 1;
} else {
return 0;
diff --git a/scripts/Dpkg/Version.pm b/scripts/Dpkg/Version.pm
index a24999c..c534ff4 100644
--- a/scripts/Dpkg/Version.pm
+++ b/scripts/Dpkg/Version.pm
@@ -26,17 +26,17 @@ use Dpkg::ErrorHandling;
use Dpkg::Gettext;
use base qw(Exporter);
-our @EXPORT = qw(version_compare version_compare_op
- version_normalize_cmp_op version_compare_string
+our @EXPORT = qw(version_compare version_compare_relation
+ version_normalize_relation version_compare_string
version_compare_part version_split_digits version_check
- CMP_OP_LT CMP_OP_LE CMP_OP_EQ CMP_OP_GE CMP_OP_GT);
+ REL_LT REL_LE REL_EQ REL_GE REL_GT);
use constant {
- CMP_OP_LT => '<<',
- CMP_OP_LE => '<=',
- CMP_OP_EQ => '=',
- CMP_OP_GE => '>=',
- CMP_OP_GT => '>>',
+ REL_LT => '<<',
+ REL_LE => '<=',
+ REL_EQ => '=',
+ REL_GE => '>=',
+ REL_GT => '>>',
};
use overload
@@ -176,64 +176,64 @@ sub version_compare($$) {
return $va <=> $vb;
}
-=item version_compare_op($a, $op, $b)
+=item version_compare_relation($a, $rel, $b)
Returns the result (0 or 1) of the given comparison operation. This
function is implemented on top of version_compare().
-Allowed values for $op are the exported constants CMP_OP_GT, CMP_OP_GE,
-CMP_OP_EQ, CMP_OP_LE, CMP_OP_LT. Use version_normalize_cmp_op() if you
+Allowed values for $rel are the exported constants REL_GT, REL_GE,
+REL_EQ, REL_LE, REL_LT. Use version_normalize_relation() if you
have an input string containing the operator.
=cut
-sub version_compare_op($$$) {
+sub version_compare_relation($$$) {
my ($a, $op, $b) = @_;
my $res = version_compare($a, $b);
- if ($op eq CMP_OP_GT) {
+ if ($op eq REL_GT) {
return $res > 0;
- } elsif ($op eq CMP_OP_GE) {
+ } elsif ($op eq REL_GE) {
return $res >= 0;
- } elsif ($op eq CMP_OP_EQ) {
+ } elsif ($op eq REL_EQ) {
return $res == 0;
- } elsif ($op eq CMP_OP_LE) {
+ } elsif ($op eq REL_LE) {
return $res <= 0;
- } elsif ($op eq CMP_OP_LT) {
+ } elsif ($op eq REL_LT) {
return $res < 0;
} else {
- internerr("unsupported operator for version_compare_op(): '$op'");
+ internerr("unsupported relation for version_compare_relation(): '$op'");
}
}
-=item my $cmp_op = version_normalize_cmp_op($op)
+=item my $rel = version_normalize_relation($rel_string)
-Returns the normalized constant of the comparison operator $op (a value
-among CMP_OP_GT, CMP_OP_GE, CMP_OP_EQ, CMP_OP_LE and CMP_OP_LT). Supported
-operators names in input are: "gt", "ge", "eq", "le", "lt", ">>", ">=",
+Returns the normalized constant of the relation $rel (a value
+among REL_GT, REL_GE, REL_EQ, REL_LE and REL_LT). Supported
+relations names in input are: "gt", "ge", "eq", "le", "lt", ">>", ">=",
"=", "<=", "<<". ">" and "<" are also supported but should not be used as
they are obsolete aliases of ">=" and "<=".
=cut
-sub version_normalize_cmp_op($) {
+sub version_normalize_relation($) {
my $op = shift;
- warning("operator %s is deprecated: use %s or %s",
+ warning("relation %s is deprecated: use %s or %s",
$op, "$op$op", "$op=") if ($op eq '>' or $op eq '<');
if ($op eq '>>' or $op eq 'gt') {
- return CMP_OP_GT;
+ return REL_GT;
} elsif ($op eq '>=' or $op eq 'ge' or $op eq '>') {
- return CMP_OP_GE;
+ return REL_GE;
} elsif ($op eq '=' or $op eq 'eq') {
- return CMP_OP_EQ;
+ return REL_EQ;
} elsif ($op eq '<=' or $op eq 'le' or $op eq '<') {
- return CMP_OP_LE;
+ return REL_LE;
} elsif ($op eq '<<' or $op eq 'lt') {
- return CMP_OP_LT;
+ return REL_LT;
} else {
- internerr("bad comparison operator '$op'");
+ internerr("bad relation '$op'");
}
}
diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl
index 0fc3238..9bde36e 100755
--- a/scripts/dpkg-genchanges.pl
+++ b/scripts/dpkg-genchanges.pl
@@ -203,8 +203,8 @@ $substvars->set_arch_substvars();
$substvars->parse($varlistfile) if -e $varlistfile;
if (defined($prev_changelog) and
- version_compare_op($changelog->{"Version"}, CMP_OP_LT,
- $prev_changelog->{"Version"}))
+ version_compare_relation($changelog->{"Version"}, REL_LT,
+ $prev_changelog->{"Version"}))
{
warning(_g("the current version (%s) is smaller than the previous one
(%s)"),
$changelog->{"Version"}, $prev_changelog->{"Version"})
diff --git a/scripts/dpkg-scanpackages.pl b/scripts/dpkg-scanpackages.pl
index 6b9789a..173377b 100755
--- a/scripts/dpkg-scanpackages.pl
+++ b/scripts/dpkg-scanpackages.pl
@@ -203,8 +203,8 @@ FILE:
if (defined($packages{$p}) and not $options{multiversion}) {
foreach (@{$packages{$p}}) {
- if (version_compare_op($fields->{'Version'}, CMP_OP_GT,
- $_->{'Version'}))
+ if (version_compare_relation($fields->{'Version'}, REL_GT,
+ $_->{'Version'}))
{
warning(_g("Package %s (filename %s) is repeat but newer
version;"),
$p, $fn);
diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl
index 56c5ea1..77820fd 100755
--- a/scripts/dpkg-shlibdeps.pl
+++ b/scripts/dpkg-shlibdeps.pl
@@ -452,8 +452,8 @@ sub filter_deps {
$stronger = 0; # If the dep is unversionned
} elsif ($depseen{$dep} eq '') {
$stronger = 1; # If the dep seen is unversionned
- } elsif (version_compare_op($depseen{$dep}, CMP_OP_GT,
- $dependencies{$field}{$dep})) {
+ } elsif (version_compare_relation($depseen{$dep}, REL_GT,
+ $dependencies{$field}{$dep})) {
# The version of the dep seen is stronger...
$stronger = 0;
} else {
@@ -562,7 +562,7 @@ sub get_min_version_from_deps {
my $minver = get_min_version_from_deps($subdep, $pkg);
next if not defined $minver;
if (defined $res) {
- if (version_compare_op($minver, CMP_OP_GT, $res)) {
+ if (version_compare_relation($minver, REL_GT, $res)) {
$res = $minver;
}
} else {
@@ -581,8 +581,8 @@ sub update_dependency_version {
defined($dependencies{$cur_field}{$subdep}))
{
if ($dependencies{$cur_field}{$subdep} eq '' or
- version_compare_op($minver, CMP_OP_GT,
- $dependencies{$cur_field}{$subdep}))
+ version_compare_relation($minver, REL_GT,
+ $dependencies{$cur_field}{$subdep}))
{
$dependencies{$cur_field}{$subdep} = $minver;
}
diff --git a/scripts/t/100_Dpkg_Version.t b/scripts/t/100_Dpkg_Version.t
index 1605fc4..e118bed 100644
--- a/scripts/t/100_Dpkg_Version.t
+++ b/scripts/t/100_Dpkg_Version.t
@@ -73,13 +73,13 @@ foreach my $case (@tests) {
is(version_compare($a, $b), $res, "$a cmp $b => $res");
is($va <=> $vb, $res, "Dpkg::Version($a) <=> Dpkg::Version($b) => $res");
foreach my $op (@ops) {
- my $norm_op = version_normalize_cmp_op($op);
+ my $norm_op = version_normalize_relation($op);
if ($truth->{$res}{$op}) {
- ok(version_compare_op($a, $norm_op, $b), "$a $op $b => true");
+ ok(version_compare_relation($a, $norm_op, $b), "$a $op $b => true");
ok(obj_vercmp($va, $op, $vb), "Dpkg::Version($a) $op
Dpkg::Version($b) => true");
ok(dpkg_vercmp($a, $op, $b), "dpkg --compare-versions $a $op $b =>
true");
} else {
- ok(!version_compare_op($a, $norm_op, $b), "$a $op $b => false");
+ ok(!version_compare_relation($a, $norm_op, $b), "$a $op $b =>
false");
ok(!obj_vercmp($va, $op, $vb), "Dpkg::Version($a) $op
Dpkg::Version($b) => false");
ok(!dpkg_vercmp($a, $op, $b), "dpkg --compare-versions $a $op $b =>
false");
}
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]