[dpkg] 85/192: perl: Use -> operator for function variables

Ximin Luo infinity0 at debian.org
Tue Oct 17 11:04:03 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch pu/reproducible_builds
in repository dpkg.

commit 99b3e1c276af88327b5f9423cfdf75afead28018
Author: Guillem Jover <guillem at debian.org>
Date:   Fri Jul 14 02:03:29 2017 +0200

    perl: Use -> operator for function variables
---
 debian/changelog                  | 2 ++
 scripts/Dpkg/Deps.pm              | 6 +++---
 scripts/Dpkg/Dist/Files.pm        | 2 +-
 scripts/Dpkg/Exit.pm              | 2 +-
 scripts/Dpkg/Index.pm             | 4 ++--
 scripts/Dpkg/Shlibs/SymbolFile.pm | 4 ++--
 scripts/Dpkg/Source/Patch.pm      | 6 +++---
 scripts/dpkg-buildpackage.pl      | 2 +-
 scripts/dpkg-mergechangelogs.pl   | 6 +++---
 scripts/t/Dpkg_Compression.t      | 4 ++--
 10 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 307f31d..c788319 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -41,6 +41,8 @@ dpkg (1.19.0) UNRELEASED; urgency=medium
     - Clarify that the Testsuite field is comma-separarted.
     - Fix update-alternatives man page section in alternatives/README file
       reference. Closes: #872309
+  * Code internals:
+    - Switch perl code to use -> operator for function variables.
   * Build system:
     - Require Perl 5.20.2, the version in Debian oldstable (jessie).
     - Use new gcc-7 -Wrestrict and -Wshift-negative-value warnings if
diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm
index 0d5652b..f2d0742 100644
--- a/scripts/Dpkg/Deps.pm
+++ b/scripts/Dpkg/Deps.pm
@@ -353,15 +353,15 @@ sub deps_iterate {
             return unless defined $dep;
 
             if ($dep->isa('Dpkg::Deps::Simple')) {
-                return unless &{$callback_func}($dep);
+                return unless $callback_func->($dep);
             } else {
-                return unless &{$visitor_func}($dep->get_deps());
+                return unless $visitor_func->($dep->get_deps());
             }
         }
         return 1;
     };
 
-    return &{$visitor_func}($deps);
+    return $visitor_func->($deps);
 }
 
 =item deps_compare($a, $b)
diff --git a/scripts/Dpkg/Dist/Files.pm b/scripts/Dpkg/Dist/Files.pm
index 347f58e..c2c426b 100644
--- a/scripts/Dpkg/Dist/Files.pm
+++ b/scripts/Dpkg/Dist/Files.pm
@@ -157,7 +157,7 @@ sub filter {
     foreach my $filename (keys %{$self->{files}}) {
         my $file = $self->{files}->{$filename};
 
-        if (not &$keep($file) or &$remove($file)) {
+        if (not $keep->($file) or $remove->($file)) {
             delete $self->{files}->{$filename};
         }
     }
diff --git a/scripts/Dpkg/Exit.pm b/scripts/Dpkg/Exit.pm
index b98b949..5e513b4 100644
--- a/scripts/Dpkg/Exit.pm
+++ b/scripts/Dpkg/Exit.pm
@@ -75,7 +75,7 @@ Run the registered exit handlers.
 =cut
 
 sub run_exit_handlers {
-    &$_() foreach (reverse @handlers);
+    $_->() foreach (reverse @handlers);
 }
 
 sub _exit_handler {
diff --git a/scripts/Dpkg/Index.pm b/scripts/Dpkg/Index.pm
index 37fd3c7..bcee620 100644
--- a/scripts/Dpkg/Index.pm
+++ b/scripts/Dpkg/Index.pm
@@ -314,7 +314,7 @@ sub get_keys {
 	    } @selected;
 	} elsif (ref($crit{$s_crit}) eq 'CODE') {
 	    @selected = grep {
-		&{$crit{$s_crit}}($self->{items}{$_}{$s_crit});
+		$crit{$s_crit}->($self->{items}{$_}{$s_crit});
 	    } @selected;
 	} else {
 	    @selected = grep {
@@ -397,7 +397,7 @@ sub sort {
     my ($self, $func) = @_;
     if (defined $func) {
 	@{$self->{order}} = sort {
-	    &$func($self->{items}{$a}, $self->{items}{$b})
+	    $func->($self->{items}{$a}, $self->{items}{$b})
 	} @{$self->{order}};
     } else {
 	@{$self->{order}} = sort @{$self->{order}};
diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm b/scripts/Dpkg/Shlibs/SymbolFile.pm
index 0b47ed2..6f7452b 100644
--- a/scripts/Dpkg/Shlibs/SymbolFile.pm
+++ b/scripts/Dpkg/Shlibs/SymbolFile.pm
@@ -366,7 +366,7 @@ sub find_matching_pattern {
 		if (my $alias = $converter->convert_to_alias($name)) {
 		    if ($alias && exists $aliases->{$alias}) {
 			$pattern = $aliases->{$alias};
-			last if &$pattern_ok($pattern);
+			last if $pattern_ok->($pattern);
 			$pattern = undef; # otherwise not found yet
 		    }
 		}
@@ -376,7 +376,7 @@ sub find_matching_pattern {
 	# Now try generic patterns and use the first that matches
 	if (not defined $pattern) {
 	    for my $p (@{$obj->{patterns}{generic}}) {
-		if (&$pattern_ok($p) && $p->matches_rawname($name)) {
+		if ($pattern_ok->($p) && $p->matches_rawname($name)) {
 		    $pattern = $p;
 		    last;
 		}
diff --git a/scripts/Dpkg/Source/Patch.pm b/scripts/Dpkg/Source/Patch.pm
index 22e9d21..e5ad542 100644
--- a/scripts/Dpkg/Source/Patch.pm
+++ b/scripts/Dpkg/Source/Patch.pm
@@ -113,7 +113,7 @@ sub add_diff_file {
     while (<$diffgen>) {
         if (m/^(?:binary|[^-+\@ ].*\bdiffer\b)/i) {
             $binary = 1;
-            &$handle_binary($self, $old, $new, %opts);
+            $handle_binary->($self, $old, $new, %opts);
             last;
         } elsif (m/^[-+\@ ]/) {
             $difflinefound++;
@@ -162,7 +162,7 @@ sub add_diff_directory {
     my %files_in_new;
     my $scan_new = sub {
         my $fn = (length > length($new)) ? substr($_, length($new) + 1) : '.';
-        return if &$diff_ignore($fn);
+        return if $diff_ignore->($fn);
         $files_in_new{$fn} = 1;
         lstat("$new/$fn") or syserr(g_('cannot stat file %s'), "$new/$fn");
         my $mode = S_IMODE((lstat(_))[2]);
@@ -222,7 +222,7 @@ sub add_diff_directory {
     };
     my $scan_old = sub {
         my $fn = (length > length($old)) ? substr($_, length($old) + 1) : '.';
-        return if &$diff_ignore($fn);
+        return if $diff_ignore->($fn);
         return if $files_in_new{$fn};
         lstat("$old/$fn") or syserr(g_('cannot stat file %s'), "$old/$fn");
         if (-f _) {
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index dd17abb..75ea4d6 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -707,7 +707,7 @@ sub run_hook {
         }
     };
 
-    $cmd =~ s/\%(.)/&$subst_hook_var($1)/eg;
+    $cmd =~ s/\%(.)/$subst_hook_var->($1)/eg;
 
     withecho($cmd);
 }
diff --git a/scripts/dpkg-mergechangelogs.pl b/scripts/dpkg-mergechangelogs.pl
index c66b721..7fd11fc 100755
--- a/scripts/dpkg-mergechangelogs.pl
+++ b/scripts/dpkg-mergechangelogs.pl
@@ -250,9 +250,9 @@ sub join_lines($) {
 sub merge_block($$$;&) {
     my ($o, $a, $b, $preprocess) = @_;
     $preprocess //= \&join_lines;
-    $o = &$preprocess($o) if defined($o);
-    $a = &$preprocess($a) if defined($a);
-    $b = &$preprocess($b) if defined($b);
+    $o = $preprocess->($o) if defined $o;
+    $a = $preprocess->($a) if defined $a;
+    $b = $preprocess->($b) if defined $b;
     return 1 if not defined($a) and not defined($b);
     if (defined($a) and defined($b) and ($a eq $b)) {
 	unshift @result, $a;
diff --git a/scripts/t/Dpkg_Compression.t b/scripts/t/Dpkg_Compression.t
index f2d30e3..3a2be11 100644
--- a/scripts/t/Dpkg_Compression.t
+++ b/scripts/t/Dpkg_Compression.t
@@ -36,7 +36,7 @@ sub test_write {
     printf { $fh } '%s', $lines[2];
     close $fh or die 'close failed';
 
-    &$check_result($filename, 'std functions');
+    $check_result->($filename, 'std functions');
 
     unlink $filename or die "cannot unlink $filename";
 
@@ -47,7 +47,7 @@ sub test_write {
     $fh->printf('%s', $lines[2]);
     $fh->close() or die 'close failed';
 
-    &$check_result($filename, 'IO::Handle methods');
+    $check_result->($filename, 'IO::Handle methods');
 }
 
 sub check_uncompressed {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list