develooper Front page | perl.perl5.porters | Postings from July 2018

require/caller file name normalization bug????

From:
bulk88
Date:
July 18, 2018 07:04
Subject:
require/caller file name normalization bug????
Message ID:
20180718070424.30498.qmail@lists-nntp.develooper.com
-----------------------------------------------
C:\perl528\srcnew>perl  -e"@INC = ('.\lib'); require Cwd;"
b4 .\lib/Cwd.pm at .\lib/XSLoader.pm line 42.
af .\lib at .\lib/XSLoader.pm line 44.
-----------------------------------------------
-----------------------------------------------
C:\perl528\srcnew>perl  -e"@INC = ('./lib'); require Cwd;"
b4 lib/Cwd.pm at lib/XSLoader.pm line 42.
af lib at lib/XSLoader.pm line 44.
bad DY at lib/XSLoader.pm line 117.
Compilation failed in require at -e line 1.
-----------------------------------------------

Why does XSLoader call full DynaLoader with a unix INC path but not a 
Windows INC path? Why did the "./" disappear but ".\" does not in how 
caller/require works?

Eventually the Unix style INC causes

---------------------------
         FOUND: {
             for (@INC) {
                 if ($_ eq $modlibname) {
                     last FOUND;
                 }
             }
---------------------------
to run, and with a unix path "./lib" ($_) vs "lib" ($modlibname) is not 
"eq" so it calls XSLoader::bootstrap_inherit();

modified by me code sections

--------------------------
sub load {
     package DynaLoader;

     my ($caller, $modlibname) = caller();
     my $module = $caller;

     if (@_) {
         $module = $_[0];
     } else {
         $_[0] = $module;
     }

     # work with static linking too
     my $boots = "$module\::bootstrap";
     goto &$boots if defined &$boots;

     goto \&XSLoader::bootstrap_inherit unless $module and defined 
&dl_load_file;

     my @modparts = split(/::/,$module);
     my $modfname = $modparts[-1];
     my $modfname_orig = $modfname; # For .bs file search

     my $modpname = join('/',@modparts);
     my $c = () = split(/::/,$caller,-1);
     warn "b4 $modlibname";
     $modlibname =~ s,[\\/][^\\/]+$,, while $c--;    # Q&D basename
     warn "af $modlibname";
----------------------------
and
----------------------------
sub bootstrap_inherit {
     die "bad DY";
     require DynaLoader;
     goto \&DynaLoader::bootstrap_inherit;
}
----------------------------



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About