This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Further simplify XSLoader .bs file handling
[perl5.git] / dist / XSLoader / XSLoader_pm.PL
index 749f72d..e095388 100644 (file)
@@ -4,14 +4,14 @@ use Config;
 eval { require DynaLoader };
 
 1 while unlink "XSLoader.pm";
-open OUT, ">XSLoader.pm" or die $!;
+open OUT, '>', 'XSLoader.pm' or die $!;
 print OUT <<'EOT';
-# Generated from XSLoader.pm.PL (resolved %Config::Config value)
+# Generated from XSLoader_pm.PL (resolved %Config::Config value)
 # This file is unique for every OS
 
 package XSLoader;
 
-$VERSION = "0.21";
+$VERSION = "0.28";
 
 #use strict;
 
@@ -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,
@@ -131,14 +143,8 @@ print OUT <<'EOT';
     my $bs = $file;
     $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library
 
-    if (-s $bs) { # only read file if it's not empty
-#       print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug;
-        eval { do $bs; };
-        warn "$bs: $@\n" if $@;
-       goto \&XSLoader::bootstrap_inherit;
-    }
-
-    goto \&XSLoader::bootstrap_inherit if not -f $file;
+    # This calls DynaLoader::bootstrap, which will load the .bs file if present
+    goto \&XSLoader::bootstrap_inherit if not -f $file or -s $bs;
 
     my $bootname = "boot_$module";
     $bootname =~ s/\W/_/g;
@@ -243,7 +249,7 @@ XSLoader - Dynamically load C libraries into Perl code
 
 =head1 VERSION
 
-Version 0.17
+Version 0.24
 
 =head1 SYNOPSIS