Skip to content

Commit

Permalink
Provide strict compliance for DynaLoader and XSLoader
Browse files Browse the repository at this point in the history
Add warnings to tests.
  • Loading branch information
toddr committed Feb 4, 2021
1 parent a1325b9 commit 317c45d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
11 changes: 7 additions & 4 deletions dist/XSLoader/XSLoader_pm.PL
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use strict;
use warnings;

use Config;
# We require DynaLoader to make sure that mod2fname is loaded
eval { require DynaLoader };
Expand All @@ -9,11 +11,12 @@ print OUT <<'EOT';
# Generated from XSLoader_pm.PL (resolved %Config::Config value)
# This file is unique for every OS
package XSLoader;
use strict;
no strict 'refs';
$VERSION = "0.30"; # remember to update version in POD!
package XSLoader;
#use strict;
our $VERSION = "0.31"; # remember to update version in POD!
package DynaLoader;
Expand Down Expand Up @@ -252,7 +255,7 @@ XSLoader - Dynamically load C libraries into Perl code
=head1 VERSION
Version 0.30
Version 0.31
=head1 SYNOPSIS
Expand Down
2 changes: 2 additions & 0 deletions dist/XSLoader/t/XSLoader.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!perl -T

use strict;
use warnings;

use Config;

my $db_file;
Expand Down
23 changes: 16 additions & 7 deletions ext/DynaLoader/DynaLoader_pm.PL
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ print OUT <<'EOT';
# Generated from DynaLoader_pm.PL, this file is unique for every OS
use strict;
package DynaLoader;
# And Gandalf said: 'Many folk like to know beforehand what is to
Expand All @@ -88,9 +90,12 @@ package DynaLoader;
# Tim.Bunce@ig.co.uk, August 1994
BEGIN {
$VERSION = '1.50';
our $VERSION = '1.50';
}
our (@dl_library_path, @dl_resolve_using, @dl_require_symbols,
$dl_debug, @dl_librefs, @dl_modules, @dl_shared_objects);
EOT

if (!$ENV{PERL_BUILD_EXPAND_CONFIG_VARS}) {
Expand Down Expand Up @@ -119,14 +124,14 @@ sub dl_load_flags { 0x00 }
EOT

if ($ENV{PERL_BUILD_EXPAND_CONFIG_VARS}) {
print OUT "(\$dl_dlext, \$dl_so, \$dlsrc) = (",
print OUT "our (\$dl_dlext, \$dl_so, \$dlsrc) = (",
to_string($Config{'dlext'}), ",",
to_string($Config{'so'}), ",",
to_string($Config{'dlsrc'}), ")\n;" ;
}
else {
print OUT <<'EOT';
($dl_dlext, $dl_so, $dlsrc) = @Config::Config{qw(dlext so dlsrc)};
our ($dl_dlext, $dl_so, $dlsrc) = @Config::Config{qw(dlext so dlsrc)};
EOT
}

Expand All @@ -141,7 +146,7 @@ print OUT expand_os_specific(<<'EOT');
# inefficient to define on systems that don't need it.
$Is_VMS = $^O eq 'VMS';
<</$^O-eq-VMS>>
$do_expand = <<$^O-eq-VMS>>1<<|$^O-eq-VMS>>0<</$^O-eq-VMS>>;
my $do_expand = <<$^O-eq-VMS>>1<<|$^O-eq-VMS>>0<</$^O-eq-VMS>>;
@dl_require_symbols = (); # names of symbols we need<<$^O-eq-freemint>>
@dl_resolve_using = (); # names of files to link with<</$^O-eq-freemint>><<$^O-eq-hpux>>
Expand Down Expand Up @@ -292,6 +297,8 @@ sub croak { require Carp; Carp::croak(@_) }
sub bootstrap_inherit {
my $module = $_[0];
no strict qw/refs vars/;
local *isa = *{"$module\::ISA"};
local @isa = (@isa, 'DynaLoader');
# Cannot goto due to delocalization. Will report errors on a wrong line?
Expand All @@ -300,9 +307,9 @@ sub bootstrap_inherit {
sub bootstrap {
# use local vars to enable $module.bs script to edit values
local(@args) = @_;
local($module) = $args[0];
local(@dirs, $file);
local our (@args) = @_;
local our ($module) = $args[0];
local our (@dirs, $file);
unless ($module) {
require Carp;
Expand Down Expand Up @@ -558,6 +565,8 @@ sub dl_find_symbol_anywhere
return undef;
}
1;
__END__
=head1 NAME
Expand Down
2 changes: 2 additions & 0 deletions ext/DynaLoader/Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use strict;
use warnings;

use ExtUtils::MakeMaker;

my $is_mswin = $^O eq 'MSWin32';
Expand Down
2 changes: 2 additions & 0 deletions ext/DynaLoader/t/DynaLoader.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/perl -wT

use strict;
use warnings;

use Config;
push @INC, '.';
if (-f 't/test.pl') {
Expand Down

0 comments on commit 317c45d

Please sign in to comment.