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:27:28 +0100 |
commit | 0305f4018f7ef3523ba67f7bb072c25abe890067 (patch) | |
tree | e8161509d392da76e211258385c5d57e5306792c | |
parent | 7b5003b4f4213ca694d03577b95244f70a5e170c (diff) | |
download | perl-0305f4018f7ef3523ba67f7bb072c25abe890067.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 e0aed87375..85148de3ef 100644 --- a/dist/XSLoader/XSLoader_pm.PL +++ b/dist/XSLoader/XSLoader_pm.PL @@ -90,8 +90,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, |