]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Consistently use ‘our’ instead of ‘use vars’ in Perl.
authorZack Weinberg <zackw@panix.com>
Mon, 21 Sep 2020 18:33:52 +0000 (14:33 -0400)
committerZack Weinberg <zackw@panix.com>
Mon, 21 Sep 2020 18:33:52 +0000 (14:33 -0400)
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.

bin/autoheader.in
bin/autoscan.in
lib/Autom4te/C4che.pm
lib/Autom4te/ChannelDefs.pm
lib/Autom4te/General.pm

index 64f90de4885e0eec029a494df9ad7e1a29b9cb48..29d0fe528d518e16ceb5e2112f0a578e40e7239f 100644 (file)
@@ -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;
index 83e6d8f4441559778a67a6aad8156ab83bf02e26..99df49291c1243857f17b59320993c0f0c8f2fec 100644 (file)
@@ -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
index 225fa2032d16f36c19cd27a029c8c7a877cd91b8..5e3bea37dd34b5f6f450780784c372bddbc830d2 100644 (file)
@@ -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)>
 
index 15f583cf04228e115e09673d3f1d4c642f3c0add..84e634e82e1169079dbdede4ed4e08894378fe0c 100644 (file)
@@ -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
 
index 95e9bde93d3500803f22aaaebf29e7af9c9d110e..010045754d0bf078df7de390936a73bd8d10da9e 100644 (file)
@@ -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