Change 34013 by [EMAIL PROTECTED] on 2008/06/07 15:12:43

        Integrate:
        [ 33955]
        Integrate:
        ...
        
        [ 33927]
        Subject: [PATCH] lib.pm should not warn about loading .par files
        From: Paul Fenwick <[EMAIL PROTECTED]>
        Date: Thu, 22 May 2008 23:24:34 +1000
        Message-ID: <[EMAIL PROTECTED]>
        
        ...
        
        [ 34011]
        Integrate:
        [ 33973]
        Subject: [PATCH] Re: recent 'lib.pm' change => dual-life lib.pm
        From: Steffen Mueller <[EMAIL PROTECTED]>
        Date: Tue, 27 May 2008 13:50:05 +0200
        Message-ID: <[EMAIL PROTECTED]>
        
        [ 33980]
        Subject: [PATCH] Fix for lib.pm Config detection
        From: Steffen Mueller <[EMAIL PROTECTED]>
        Date: Sun, 01 Jun 2008 17:36:55 +0200
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

... //depot/maint-5.8/perl/lib/lib.t#3 integrate
... //depot/maint-5.8/perl/lib/lib_pm.PL#6 integrate

Differences ...

==== //depot/maint-5.8/perl/lib/lib.t#3 (text) ====
Index: perl/lib/lib.t
--- perl/lib/lib.t#2~18080~     2002-11-03 21:23:04.000000000 -0800
+++ perl/lib/lib.t      2008-06-07 08:12:43.000000000 -0700
@@ -2,7 +2,7 @@
 
 BEGIN {
     chdir 't';
-    @INC = '../lib';
+    unshift @INC, '../lib';
     @OrigINC = @INC;
 }
 

==== //depot/maint-5.8/perl/lib/lib_pm.PL#6 (text) ====
Index: perl/lib/lib_pm.PL
--- perl/lib/lib_pm.PL#5~30468~ 2007-03-05 10:08:59.000000000 -0800
+++ perl/lib/lib_pm.PL  2008-06-07 08:12:43.000000000 -0700
@@ -6,17 +6,45 @@
 my $origdir = cwd;
 chdir dirname($0);
 my $file = basename($0, '.PL');
-$file =~ s!_(pm)$!.$1!i;
+$file =~ s/_(pm)$/.$1/i;
 
 my $useConfig;
 my $Config_archname;
 my $Config_version;
 my $Config_inc_version_list;
 
-# Expand the variables only if explicitly requested because
-# otherwise relocating Perl becomes much harder.
+# Expand the variables only if explicitly requested
+# or if a previously installed lib.pm does this, too
+# because otherwise relocating Perl becomes much harder.
 
+my $expand_config_vars = 0;
 if ($ENV{PERL_BUILD_EXPAND_CONFIG_VARS}) {
+  $expand_config_vars = 1;
+}
+elsif (exists $ENV{PERL_BUILD_EXPAND_CONFIG_VARS}) {
+  $expand_config_vars = 0;
+}
+else {
+  eval <<'HERE';
+  require lib;
+  my $lib_file = $INC{"lib.pm"};
+  open my $fh, '<', $lib_file
+    or die "Could not open file '$lib_file' for reading: $!";
+  my $ConfigRegex = qr/(?:use|require)\s+Config(?:\s+|;)/;
+  my $found_config = 0;
+  while (defined($_ = <$fh>)) {
+    # crude heuristics to check that we were using Config
+    if (/^\s*$ConfigRegex/ || /^\s*eval.*$ConfigRegex/) {
+      $found_config = 1;
+      last;
+    }
+  }
+  $expand_config_vars = $found_config ? 0 : 1;
+HERE
+  $expand_config_vars = 0 if $@;
+}
+
+if ($expand_config_vars) {
     $useConfig = '';
     $Config_archname = qq('$Config{archname}');
     $Config_version  = qq('$Config{version}');
@@ -24,7 +52,7 @@
        reverse split / /, $Config{inc_version_list};
     $Config_inc_version_list =
        @Config_inc_version_list ?
-           qq(@Config_inc_version_list) : q(());
+           qq(qw(@Config_inc_version_list)) : q(());
 } else {
     $useConfig = 'use Config;';
     $Config_archname = q($Config{archname});
@@ -58,7 +86,7 @@
 print OUT <<'!NO!SUBS!';
 
 our @ORIG_INC = @INC;  # take a handy copy of 'original' value
-our $VERSION = '0.5565';
+our $VERSION = '0.57';
 my $Is_MacOS = $^O eq 'MacOS';
 my $Mac_FS;
 if ($Is_MacOS) {
@@ -79,7 +107,7 @@
 
        $path = _nativize($path);
 
-       if (-e $path && ! -d _) {
+       if ($path !~ /\.par$/i && -e $path && ! -d _) {
            require Carp;
            Carp::carp("Parameter to use lib must be directory, not file");
        }
@@ -244,14 +272,40 @@
 work, and Unix-style paths are converted properly to Mac-style paths
 before being added to @INC).
 
+If you try to add a file to @INC as follows:
+
+  use lib 'this_is_a_file.txt';
+
+C<lib> will warn about this. The sole exceptions are files with the
+C<.par> extension which are intended to be used as libraries.
+
 =head1 SEE ALSO
 
 FindBin - optional module which deals with paths relative to the source file.
 
+PAR - optional module which can treat C<.par> files as Perl libraries.
+
 =head1 AUTHOR
 
 Tim Bunce, 2nd June 1995.
 
+C<lib> is maintained by the perl5-porters. Please direct
+any questions to the canonical mailing list. Anything that
+is applicable to the CPAN release can be sent to its maintainer,
+though.
+
+Maintainer: The Perl5-Porters <[EMAIL PROTECTED]>
+
+Maintainer of the CPAN release: Steffen Mueller <[EMAIL PROTECTED]>
+
+=head1 COPYRIGHT AND LICENSE
+
+This package has been part of the perl core since perl 5.001.
+It has been released separately to CPAN so older installations
+can benefit from bug fixes.
+
+This package has the same copyright and license as the perl core.
+
 =cut
 !NO!SUBS!
 
End of Patch.

Reply via email to