Explorar o código

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.
Raphaël Hertzog %!s(int64=17) %!d(string=hai) anos
pai
achega
00a9e0039e

+ 4 - 4
scripts/Dpkg/Changelog.pm

@@ -257,7 +257,7 @@ sub __sanity_check_range {
         warning(_g("'%s' option specifies non-existing version"), "since");
         warning(_g("'%s' option specifies non-existing version"), "since");
         warning(_g("use newest entry that is smaller than the one specified"));
         warning(_g("use newest entry that is smaller than the one specified"));
         foreach my $v (@versions) {
         foreach my $v (@versions) {
-            if (version_compare_op($v, CMP_OP_LT, $$since)) {
+            if (version_compare_relation($v, REL_LT, $$since)) {
                 $$since = $v;
                 $$since = $v;
                 last;
                 last;
             }
             }
@@ -274,7 +274,7 @@ sub __sanity_check_range {
         warning(_g("use oldest entry that is bigger than the one specified"));
         warning(_g("use oldest entry that is bigger than the one specified"));
         my $oldest;
         my $oldest;
         foreach my $v (@versions) {
         foreach my $v (@versions) {
-            if (version_compare_op($v, CMP_OP_GT, $$from)) {
+            if (version_compare_relation($v, REL_GT, $$from)) {
                 $oldest = $v;
                 $oldest = $v;
             }
             }
         }
         }
@@ -290,7 +290,7 @@ sub __sanity_check_range {
         warning(_g("use oldest entry that is bigger than the one specified"));
         warning(_g("use oldest entry that is bigger than the one specified"));
         my $oldest;
         my $oldest;
         foreach my $v (@versions) {
         foreach my $v (@versions) {
-            if (version_compare_op($v, CMP_OP_GT, $$until)) {
+            if (version_compare_relation($v, REL_GT, $$until)) {
                 $oldest = $v;
                 $oldest = $v;
             }
             }
         }
         }
@@ -305,7 +305,7 @@ sub __sanity_check_range {
         warning(_g("'%s' option specifies non-existing version"), "to");
         warning(_g("'%s' option specifies non-existing version"), "to");
         warning(_g("use newest entry that is smaller than the one specified"));
         warning(_g("use newest entry that is smaller than the one specified"));
         foreach my $v (@versions) {
         foreach my $v (@versions) {
-            if (version_compare_op($v, CMP_OP_LT, $$to)) {
+            if (version_compare_relation($v, REL_LT, $$to)) {
                 $$to = $v;
                 $$to = $v;
                 last;
                 last;
             }
             }

+ 3 - 2
scripts/Dpkg/Deps.pm

@@ -518,7 +518,7 @@ sub parse {
 	      \s*$			    # trailing spaces at end
 	      \s*$			    # trailing spaces at end
             /x;
             /x;
     $self->{package} = $1;
     $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)) {
     if (defined($3)) {
         $self->{version} = Dpkg::Version->new($3) || $3;
         $self->{version} = Dpkg::Version->new($3) || $3;
     }
     }
@@ -664,7 +664,8 @@ sub get_evaluation {
 		return 0;
 		return 0;
 	    } else {
 	    } else {
 		if (defined($param)) {
 		if (defined($param)) {
-		    if (version_compare_op($param, $self->{relation}, $self->{version})) {
+		    if (version_compare_relation($param, $self->{relation},
+						 $self->{version})) {
 			return 1;
 			return 1;
 		    } else {
 		    } else {
 			return 0;
 			return 0;

+ 30 - 30
scripts/Dpkg/Version.pm

@@ -26,17 +26,17 @@ use Dpkg::ErrorHandling;
 use Dpkg::Gettext;
 use Dpkg::Gettext;
 
 
 use base qw(Exporter);
 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
                  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 {
 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
 use overload
@@ -176,64 +176,64 @@ sub version_compare($$) {
     return $va <=> $vb;
     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
 Returns the result (0 or 1) of the given comparison operation. This
 function is implemented on top of version_compare().
 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.
 have an input string containing the operator.
 
 
 =cut
 =cut
 
 
-sub version_compare_op($$$) {
+sub version_compare_relation($$$) {
     my ($a, $op, $b) = @_;
     my ($a, $op, $b) = @_;
     my $res = version_compare($a, $b);
     my $res = version_compare($a, $b);
 
 
-    if ($op eq CMP_OP_GT) {
+    if ($op eq REL_GT) {
 	return $res > 0;
 	return $res > 0;
-    } elsif ($op eq CMP_OP_GE) {
+    } elsif ($op eq REL_GE) {
 	return $res >= 0;
 	return $res >= 0;
-    } elsif ($op eq CMP_OP_EQ) {
+    } elsif ($op eq REL_EQ) {
 	return $res == 0;
 	return $res == 0;
-    } elsif ($op eq CMP_OP_LE) {
+    } elsif ($op eq REL_LE) {
 	return $res <= 0;
 	return $res <= 0;
-    } elsif ($op eq CMP_OP_LT) {
+    } elsif ($op eq REL_LT) {
 	return $res < 0;
 	return $res < 0;
     } else {
     } 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
 "=", "<=", "<<". ">" and "<" are also supported but should not be used as
 they are obsolete aliases of ">=" and "<=".
 they are obsolete aliases of ">=" and "<=".
 
 
 =cut
 =cut
 
 
-sub version_normalize_cmp_op($) {
+sub version_normalize_relation($) {
     my $op = shift;
     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 '<');
             $op, "$op$op", "$op=") if ($op eq '>' or $op eq '<');
 
 
     if ($op eq '>>' or $op eq 'gt') {
     if ($op eq '>>' or $op eq 'gt') {
-	return CMP_OP_GT;
+	return REL_GT;
     } elsif ($op eq '>=' or $op eq 'ge' or $op eq '>') {
     } elsif ($op eq '>=' or $op eq 'ge' or $op eq '>') {
-	return CMP_OP_GE;
+	return REL_GE;
     } elsif ($op eq '=' or $op eq 'eq') {
     } elsif ($op eq '=' or $op eq 'eq') {
-	return CMP_OP_EQ;
+	return REL_EQ;
     } elsif ($op eq '<=' or $op eq 'le' or $op 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') {
     } elsif ($op eq '<<' or $op eq 'lt') {
-	return CMP_OP_LT;
+	return REL_LT;
     } else {
     } else {
-	internerr("bad comparison operator '$op'");
+	internerr("bad relation '$op'");
     }
     }
 }
 }
 
 

+ 2 - 2
scripts/dpkg-genchanges.pl

@@ -203,8 +203,8 @@ $substvars->set_arch_substvars();
 $substvars->parse($varlistfile) if -e $varlistfile;
 $substvars->parse($varlistfile) if -e $varlistfile;
 
 
 if (defined($prev_changelog) and
 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)"),
     warning(_g("the current version (%s) is smaller than the previous one (%s)"),
 	$changelog->{"Version"}, $prev_changelog->{"Version"})
 	$changelog->{"Version"}, $prev_changelog->{"Version"})

+ 2 - 2
scripts/dpkg-scanpackages.pl

@@ -203,8 +203,8 @@ FILE:
 	
 	
 	if (defined($packages{$p}) and not $options{multiversion}) {
 	if (defined($packages{$p}) and not $options{multiversion}) {
 	    foreach (@{$packages{$p}}) {
 	    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;"),
 		    warning(_g("Package %s (filename %s) is repeat but newer version;"),
 		            $p, $fn);
 		            $p, $fn);

+ 5 - 5
scripts/dpkg-shlibdeps.pl

@@ -452,8 +452,8 @@ sub filter_deps {
 	    $stronger = 0; # If the dep is unversionned
 	    $stronger = 0; # If the dep is unversionned
 	} elsif ($depseen{$dep} eq '') {
 	} elsif ($depseen{$dep} eq '') {
 	    $stronger = 1; # If the dep seen is unversionned
 	    $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...
 	    # The version of the dep seen is stronger...
 	    $stronger = 0;
 	    $stronger = 0;
 	} else {
 	} else {
@@ -562,7 +562,7 @@ sub get_min_version_from_deps {
 	    my $minver = get_min_version_from_deps($subdep, $pkg);
 	    my $minver = get_min_version_from_deps($subdep, $pkg);
 	    next if not defined $minver;
 	    next if not defined $minver;
 	    if (defined $res) {
 	    if (defined $res) {
-		if (version_compare_op($minver, CMP_OP_GT, $res)) {
+		if (version_compare_relation($minver, REL_GT, $res)) {
 		    $res = $minver;
 		    $res = $minver;
 		}
 		}
 	    } else {
 	    } else {
@@ -581,8 +581,8 @@ sub update_dependency_version {
 	    defined($dependencies{$cur_field}{$subdep}))
 	    defined($dependencies{$cur_field}{$subdep}))
 	{
 	{
 	    if ($dependencies{$cur_field}{$subdep} eq '' or
 	    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;
 		$dependencies{$cur_field}{$subdep} = $minver;
 	    }
 	    }

+ 3 - 3
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(version_compare($a, $b), $res, "$a cmp $b => $res");
     is($va <=> $vb, $res, "Dpkg::Version($a) <=> Dpkg::Version($b) => $res");
     is($va <=> $vb, $res, "Dpkg::Version($a) <=> Dpkg::Version($b) => $res");
     foreach my $op (@ops) {
     foreach my $op (@ops) {
-        my $norm_op = version_normalize_cmp_op($op);
+        my $norm_op = version_normalize_relation($op);
 	if ($truth->{$res}{$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(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");
 	    ok(dpkg_vercmp($a, $op, $b), "dpkg --compare-versions $a $op $b => true");
 	} else {
 	} 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(!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");
 	    ok(!dpkg_vercmp($a, $op, $b), "dpkg --compare-versions $a $op $b => false");
 	}
 	}