Change 17768 by [EMAIL PROTECTED] on 2002/08/25 14:02:47

        Subject: [PATCH] fix lib.pm's import() to accept readonly parameters
        From: Anton Berezin <[EMAIL PROTECTED]>
        Date: Tue, 20 Aug 2002 23:44:25 +0200
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

.... //depot/perl/lib/lib.t#3 edit
.... //depot/perl/lib/lib_pm.PL#10 edit

Differences ...

==== //depot/perl/lib/lib.t#3 (text) ====
Index: perl/lib/lib.t
--- perl/lib/lib.t#2~16942~     Fri May 31 14:42:12 2002
+++ perl/lib/lib.t      Sun Aug 25 07:02:47 2002
@@ -6,7 +6,7 @@
     @OrigINC = @INC;
 }
 
-use Test::More tests => 12;
+use Test::More tests => 13;
 use Config;
 use File::Spec;
 use File::Path;
@@ -80,6 +80,9 @@
 }
 
 no lib $Lib_Dir;
+
+unlike( do { eval 'use lib $Config{installsitelib};'; $@ || '' },
+       qr/::Config is read-only/, 'lib handles readonly stuff' );
 
 BEGIN {
     is( grep(/stuff/, @INC), 0, 'no lib' );

==== //depot/perl/lib/lib_pm.PL#10 (text) ====
Index: perl/lib/lib_pm.PL
--- perl/lib/lib_pm.PL#9~16989~ Tue Jun  4 17:07:15 2002
+++ perl/lib/lib_pm.PL  Sun Aug 25 07:02:47 2002
@@ -71,30 +71,31 @@
 
     my %names;
     foreach (reverse @_) {
-       if ($_ eq '') {
+       my $path = $_;          # we'll be modifying it, so break the alias
+       if ($path eq '') {
            require Carp;
            Carp::carp("Empty compile time value given to use lib");
        }
 
-       local $_ = _nativize($_);
+       $path = _nativize($path);
 
-       if (-e && ! -d _) {
+       if (-e $path && ! -d _) {
            require Carp;
            Carp::carp("Parameter to use lib must be directory, not file");
        }
-       unshift(@INC, $_);
+       unshift(@INC, $path);
        # Add any previous version directories we found at configure time
        foreach my $incver (@inc_version_list)
        {
            my $dir = $Is_MacOS
-               ? File::Spec->catdir( $_, $incver )
-               : "$_/$incver";
+               ? File::Spec->catdir( $path, $incver )
+               : "$path/$incver";
            unshift(@INC, $dir) if -d $dir;
        }
-       # Put a corresponding archlib directory in front of $_ if it
-       # looks like $_ has an archlib directory below it.
+       # Put a corresponding archlib directory in front of $path if it
+       # looks like $path has an archlib directory below it.
        my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir)
-           = _get_dirs($_);
+           = _get_dirs($path);
        unshift(@INC, $arch_dir)         if -d $arch_auto_dir;
        unshift(@INC, $version_dir)      if -d $version_dir;
        unshift(@INC, $version_arch_dir) if -d $version_arch_dir;
End of Patch.

Reply via email to