From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 324DD1FA10 for ; Wed, 9 Sep 2020 06:26:19 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 03/11] use "\&" where possible when referring to subroutines Date: Wed, 9 Sep 2020 06:26:10 +0000 Message-Id: <20200909062618.5940-4-e@80x24.org> In-Reply-To: <20200909062618.5940-1-e@80x24.org> References: <20200909062618.5940-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: "*foo" is ambiguous in that it may refer to a bareword file handle; so we'll use it where we can without triggering warnings. PublicInbox::TestCommon::run_script_exit required dropping the prototype, however. We'll also future-proof by dropping "use warnings" in Cgit.pm and use the less-ambiguous "//=" in Inbox.pm while we're in the area. --- lib/PublicInbox/Cgit.pm | 5 ++--- lib/PublicInbox/Inbox.pm | 2 +- lib/PublicInbox/TestCommon.pm | 4 ++-- lib/PublicInbox/WwwListing.pm | 6 +++--- t/replace.t | 8 ++++---- t/solver_git.t | 2 +- xt/msgtime_cmp.t | 2 +- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/PublicInbox/Cgit.pm b/lib/PublicInbox/Cgit.pm index 9a51b451..fb0d0e60 100644 --- a/lib/PublicInbox/Cgit.pm +++ b/lib/PublicInbox/Cgit.pm @@ -10,9 +10,8 @@ use strict; use PublicInbox::GitHTTPBackend; use PublicInbox::Git; # not bothering with Exporter for a one-off -*input_prepare = *PublicInbox::GitHTTPBackend::input_prepare; -*serve = *PublicInbox::GitHTTPBackend::serve; -use warnings; +*input_prepare = \&PublicInbox::GitHTTPBackend::input_prepare; +*serve = \&PublicInbox::GitHTTPBackend::serve; use PublicInbox::Qspawn; use PublicInbox::WwwStatic qw(r); diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 3b5ac970..b0894a7d 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -70,7 +70,7 @@ sub _cleanup_later ($) { my ($self) = @_; $cleanup_avail = cleanup_possible() if $cleanup_avail < 0; return if $cleanup_avail != 1; - $cleanup_timer ||= PublicInbox::DS::later(*cleanup_task); + $cleanup_timer //= PublicInbox::DS::later(\&cleanup_task); $CLEANUP->{"$self"} = $self; } diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index b03e93e0..42819179 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -158,7 +158,7 @@ sub _undo_redirects ($) { # The default is 2. our $run_script_exit_code; sub RUN_SCRIPT_EXIT () { "RUN_SCRIPT_EXIT\n" }; -sub run_script_exit (;$) { +sub run_script_exit { $run_script_exit_code = $_[0] // 0; die RUN_SCRIPT_EXIT; } @@ -180,7 +180,7 @@ package $pkg; use strict; use subs qw(exit); -*exit = *PublicInbox::TestCommon::run_script_exit; +*exit = \\&PublicInbox::TestCommon::run_script_exit; sub main { # the below "line" directive is a magic comment, see perlsyn(1) manpage # line 1 "$f" diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm index 365743cf..0be3764c 100644 --- a/lib/PublicInbox/WwwListing.pm +++ b/lib/PublicInbox/WwwListing.pm @@ -60,9 +60,9 @@ sub list_404 ($$) { [] } # TODO: +cgit my %VALID = ( - all => *list_all, - 'match=domain' => *list_match_domain, - 404 => *list_404, + all => \&list_all, + 'match=domain' => \&list_match_domain, + 404 => \&list_404, ); sub set_cb ($$$) { diff --git a/t/replace.t b/t/replace.t index a1e2d63b..95241adf 100644 --- a/t/replace.t +++ b/t/replace.t @@ -179,10 +179,10 @@ EOF } } -my $opt = { pre => *pad_msgs }; +my $opt = { pre => \&pad_msgs }; test_replace(2, 'basic', {}); test_replace(2, 'basic', $opt); -test_replace(2, 'basic', $opt = { %$opt, post => *pad_msgs }); +test_replace(2, 'basic', $opt = { %$opt, post => \&pad_msgs }); test_replace(2, 'basic', $opt = { %$opt, rotate_bytes => 1 }); SKIP: { @@ -190,9 +190,9 @@ SKIP: { PublicInbox::Search::load_xapian() or skip 'Search::Xapian missing', 8; for my $l (qw(medium)) { test_replace(2, $l, {}); - $opt = { pre => *pad_msgs }; + $opt = { pre => \&pad_msgs }; test_replace(2, $l, $opt); - test_replace(2, $l, $opt = { %$opt, post => *pad_msgs }); + test_replace(2, $l, $opt = { %$opt, post => \&pad_msgs }); test_replace(2, $l, $opt = { %$opt, rotate_bytes => 1 }); } }; diff --git a/t/solver_git.t b/t/solver_git.t index 78cc0edd..c162b605 100644 --- a/t/solver_git.t +++ b/t/solver_git.t @@ -41,7 +41,7 @@ $ibx->{-repo_objs} = [ $git ]; my $res; my $solver = PublicInbox::SolverGit->new($ibx, sub { $res = $_[0] }); open my $log, '+>>', "$inboxdir/solve.log" or die "open: $!"; -my $psgi_env = { 'psgi.errors' => *STDERR, 'psgi.url_scheme' => 'http', +my $psgi_env = { 'psgi.errors' => \*STDERR, 'psgi.url_scheme' => 'http', 'HTTP_HOST' => 'example.com' }; $solver->solve($psgi_env, $log, '69df7d5', {}); ok($res, 'solved a blob!'); diff --git a/xt/msgtime_cmp.t b/xt/msgtime_cmp.t index 0ce3c042..aa96be4d 100644 --- a/xt/msgtime_cmp.t +++ b/xt/msgtime_cmp.t @@ -62,7 +62,7 @@ my $fh = $git->popen(@cat); while (<$fh>) { my ($oid, $type) = split / /; next if $type ne 'blob'; - $git->cat_async($oid, *compare); + $git->cat_async($oid, \&compare); } $git->cat_async_wait; ok(1);