X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Flib_pm.PL;h=2c12be4dc7fb33304d2b3ff6678ec6f4809e40d6;hb=dfa4e5d386dd8c5329351699b02085856cdd140e;hp=8e949061a095a10ddf5a19ad22541ec61784b644;hpb=fbc36ba305ea40f50c1cc02919335f5c95d6e1b2;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/lib_pm.PL b/lib/lib_pm.PL index 8e94906..2c12be4 100644 --- a/lib/lib_pm.PL +++ b/lib/lib_pm.PL @@ -58,7 +58,7 @@ my \@inc_version_list = $Config_inc_version_list; print OUT <<'!NO!SUBS!'; our @ORIG_INC = @INC; # take a handy copy of 'original' value -our $VERSION = '0.5564'; +our $VERSION = '0.5565'; my $Is_MacOS = $^O eq 'MacOS'; my $Mac_FS; if ($Is_MacOS) { @@ -71,30 +71,31 @@ sub import { 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; @@ -111,11 +112,11 @@ sub unimport { my %names; foreach (@_) { - local $_ = _nativize($_); + my $path = _nativize($_); my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir) - = _get_dirs($_); - ++$names{$_}; + = _get_dirs($path); + ++$names{$path}; ++$names{$arch_dir} if -d $arch_auto_dir; ++$names{$version_dir} if -d $version_dir; ++$names{$version_arch_dir} if -d $version_arch_dir; @@ -133,15 +134,15 @@ sub _get_dirs { # we could use this for all platforms in the future, but leave it # Mac-only for now, until there is more time for testing it. if ($Is_MacOS) { - $arch_auto_dir = File::Spec->catdir( $_, $archname, 'auto' ); - $arch_dir = File::Spec->catdir( $_, $archname, ); - $version_dir = File::Spec->catdir( $_, $version ); - $version_arch_dir = File::Spec->catdir( $_, $version, $archname ); + $arch_auto_dir = File::Spec->catdir( $dir, $archname, 'auto' ); + $arch_dir = File::Spec->catdir( $dir, $archname, ); + $version_dir = File::Spec->catdir( $dir, $version ); + $version_arch_dir = File::Spec->catdir( $dir, $version, $archname ); } else { - $arch_auto_dir = "$_/$archname/auto"; - $arch_dir = "$_/$archname"; - $version_dir = "$_/$version"; - $version_arch_dir = "$_/$version/$archname"; + $arch_auto_dir = "$dir/$archname/auto"; + $arch_dir = "$dir/$archname"; + $version_dir = "$dir/$version"; + $version_arch_dir = "$dir/$version/$archname"; } return($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir); } @@ -149,7 +150,7 @@ sub _get_dirs { sub _nativize { my($dir) = @_; - if ($Is_MacOS && $Mac_FS) { + if ($Is_MacOS && $Mac_FS && ! -d $dir) { $dir = Mac::FileSpec::Unixish::nativize($dir); $dir .= ":" unless $dir =~ /:$/; } @@ -195,6 +196,10 @@ checks to see if a directory called $dir/$archname/auto exists. If so the $dir/$archname directory is assumed to be a corresponding architecture specific directory and is added to @INC in front of $dir. +The current value of C<$archname> can be found with this command: + + perl -V:archname + To avoid memory leaks, all trailing duplicate entries in @INC are removed.