summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2020-09-21 14:33:52 -0400
committerZack Weinberg <zackw@panix.com>2020-09-21 14:33:52 -0400
commit904d8e72e5a511dde72173a1d7f0e4c1e5bf4b79 (patch)
tree71aa750e24dc57bcb38e9c49d9b535f072ed93c0
parentf48d5cee1c57bd3c6c136fc1b83cc00871fd9aa2 (diff)
downloadautoconf-904d8e72e5a511dde72173a1d7f0e4c1e5bf4b79.tar.gz
Consistently use ‘our’ instead of ‘use vars’ in Perl.
At file scope of a file containing at most one ‘package’ declaration, ‘use vars’ is exactly equivalent to ‘our’, and the latter is preferred starting with Perl 5.6.0, which happens to be the oldest version we support. In one place ‘our’ was not actually necessary and was switched to ‘my’. (This change has already been made in Automake and applied to the shared Perl code via the previous ‘make fetch’ commit.) * lib/Autom4te/C4che.pm * lib/Autom4te/ChannelDefs.pm * lib/Autom4te/General.pm: Replace all uses of ‘use vars’ with ‘our’. * bin/autoheader.in: Replace all uses of ‘use vars’ with ‘our’. Remove an unnecessary ‘local’. * bin/autoscan.in: Convert ‘use vars’ variables to ‘my’ variables.
-rw-r--r--bin/autoheader.in6
-rw-r--r--bin/autoscan.in2
-rw-r--r--lib/Autom4te/C4che.pm8
-rw-r--r--lib/Autom4te/ChannelDefs.pm7
-rw-r--r--lib/Autom4te/General.pm26
5 files changed, 19 insertions, 30 deletions
diff --git a/bin/autoheader.in b/bin/autoheader.in
index 64f90de4..29d0fe52 100644
--- a/bin/autoheader.in
+++ b/bin/autoheader.in
@@ -49,12 +49,12 @@ use Autom4te::FileUtils;
use Autom4te::General;
use Autom4te::XFile;
-# Using 'do FILE', we need 'local' vars.
-use vars qw ($config_h %symbol %verbatim);
+# These vars must be package globals so they can be accessed by code
+# evaluated via 'do FILE', below.
+our ($config_h, %symbol, %verbatim);
# Lib files.
my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@';
-local $config_h;
my $config_h_in;
my @prepend_include;
my @include;
diff --git a/bin/autoscan.in b/bin/autoscan.in
index 83e6d8f4..99df4929 100644
--- a/bin/autoscan.in
+++ b/bin/autoscan.in
@@ -48,7 +48,7 @@ use Autom4te::FileUtils;
use Autom4te::General;
use Autom4te::XFile;
-use vars qw(@cfiles @makefiles @shfiles @subdirs %printed);
+my (@cfiles, @makefiles, @shfiles, @subdirs, %printed);
# The kind of the words we are looking for.
my @kinds = qw (function header identifier program
diff --git a/lib/Autom4te/C4che.pm b/lib/Autom4te/C4che.pm
index 225fa203..5e3bea37 100644
--- a/lib/Autom4te/C4che.pm
+++ b/lib/Autom4te/C4che.pm
@@ -46,14 +46,12 @@ use Autom4te::Request;
List of requests.
-We cannot declare it "my" as the loading, performed via "do", would
-refer to another scope, and @request would not be updated. It used to
-work with "my" vars, and I do not know whether the current behavior
-(5.6) is wanted or not.
+Must be a package global so it can be accessed by code evaluated via
+'eval', below.
=cut
-use vars qw (@request);
+our @request;
=item C<$req = Autom4te::C4che-E<gt>retrieve (%attr)>
diff --git a/lib/Autom4te/ChannelDefs.pm b/lib/Autom4te/ChannelDefs.pm
index 15f583cf..84e634e8 100644
--- a/lib/Autom4te/ChannelDefs.pm
+++ b/lib/Autom4te/ChannelDefs.pm
@@ -53,10 +53,9 @@ use warnings FATAL => 'all';
use Exporter;
-use vars qw (@EXPORT @ISA);
-@ISA = qw (Exporter);
-@EXPORT = qw (&prog_error &error &fatal &verb
- &switch_warning &parse_WARNINGS &parse_warnings);
+our @ISA = qw (Exporter);
+our @EXPORT = qw (&prog_error &error &fatal &verb
+ &switch_warning &parse_WARNINGS &parse_warnings);
=head2 CHANNELS
diff --git a/lib/Autom4te/General.pm b/lib/Autom4te/General.pm
index 95e9bde9..01004575 100644
--- a/lib/Autom4te/General.pm
+++ b/lib/Autom4te/General.pm
@@ -47,8 +47,7 @@ use Autom4te::ChannelDefs;
use Autom4te::Channels;
use Autom4te::Getopt ();
-use vars qw (@EXPORT @ISA);
-@ISA = qw (Exporter);
+our @ISA = qw (Exporter);
# Variables we define and export.
my @export_vars =
@@ -64,7 +63,7 @@ my @export_subs =
my @export_forward_subs =
qw (&basename &dirname &fileparse);
-@EXPORT = (@export_vars, @export_subs, @export_forward_subs);
+our @EXPORT = (@export_vars, @export_subs, @export_forward_subs);
# Variable we share with the main package. Be sure to have a single
@@ -83,8 +82,7 @@ incorrect execution.
=cut
-use vars qw ($debug);
-$debug = 0;
+our $debug = 0;
=item C<$force>
@@ -93,8 +91,7 @@ the output files are obsolete.
=cut
-use vars qw ($force);
-$force = undef;
+our $force = undef;
=item C<$help>
@@ -102,8 +99,7 @@ Set to the help message associated with the option C<--help>.
=cut
-use vars qw ($help);
-$help = undef;
+our $help = undef;
=item C<$me>
@@ -111,8 +107,7 @@ The name of this application, for diagnostic messages.
=cut
-use vars qw ($me);
-$me = basename ($0);
+our $me = basename ($0);
=item C<$tmp>
@@ -122,8 +117,7 @@ C<undef> otherwise.
=cut
# Our tmp dir.
-use vars qw ($tmp);
-$tmp = undef;
+our $tmp = undef;
=item C<$verbose>
@@ -132,8 +126,7 @@ users, and typically make explicit the steps being performed.
=cut
-use vars qw ($verbose);
-$verbose = 0;
+our $verbose = 0;
=item C<$version>
@@ -141,8 +134,7 @@ Set to the version message associated to the option C<--version>.
=cut
-use vars qw ($version);
-$version = undef;
+our $version = undef;
=back