diff options
author | Father Chrysostomos <sprout@cpan.org> | 2016-07-04 08:48:57 -0700 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2016-07-21 21:31:09 +0100 |
commit | 8dc3e612fd2ec9ab8b3cd3973f54d82ceb3b6f3b (patch) | |
tree | 0cea40163aea6692d89f3afe66f639d42fb30f19 | |
parent | 7099cb3d4b19649244b3ff4171da683abbd5e2bd (diff) | |
download | perl-8dc3e612fd2ec9ab8b3cd3973f54d82ceb3b6f3b.tar.gz |
Fix XSLoader to recognize drive letters
Commit 08e3451d made XSLoader confirm that the file path it got
from (caller)[2] was in @INC if it looked like a relative path.
Not taking drive letters into account, it made that @INC search
mandatory on Windows and some other systems. It still worked, but
was slightly slower.
(cherry picked from commit a651dcdf6a9151150dcf0fb6b18849d3e39b0811)
-rw-r--r-- | dist/XSLoader/XSLoader_pm.PL | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/dist/XSLoader/XSLoader_pm.PL b/dist/XSLoader/XSLoader_pm.PL index 749f72da4b..5e46c252f7 100644 --- a/dist/XSLoader/XSLoader_pm.PL +++ b/dist/XSLoader/XSLoader_pm.PL @@ -91,8 +91,20 @@ print OUT <<'EOT'; my $modpname = join('/',@modparts); my $c = () = split(/::/,$caller,-1); $modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename +EOT + +my $to_print = <<'EOT'; # Does this look like a relative path? - if ($modlibname !~ m|^[\\/]|) { + if ($modlibname !~ m{regexp}) { +EOT + +$to_print =~ s~regexp~ + $^O eq 'MSWin32' || $^O eq 'os2' || $^O eq 'cygwin' || $^O eq 'amigaos' + ? '^(?:[A-Za-z]:)?[\\\/]' # Optional drive letter + : '^/' +~e; + +print OUT $to_print, <<'EOT'; # Someone may have a #line directive that changes the file name, or # may be calling XSLoader::load from inside a string eval. We cer- # tainly do not want to go loading some code that is not in @INC, |