Front page | perl.perl5.porters |
Postings from February 2003
[patch] small lib.pm bufgixes
Thread Next
From:
Alex Vandiver
Date:
February 26, 2003 05:22
Subject:
[patch] small lib.pm bufgixes
Message ID:
1046265735.27931.247.camel@supox
Heya,
A few bugfixes to lib.pm below. I first got started on this when I
stumbled across a silly bug-in-waiting in lib.pm -- &lib::_get_dirs
grabs $dir as its argument off of @_, then proceeds to use $_ instead of
$dir as the directory. This works currently because it's only being
called as _get_dirs($_).
While searching the archives, I dug up the thread dealing with import
attempting to modify read-only values. unimport has the same bug, which
was not patched at the same time. It is below, though.
Finally, I added a catch so that CODE blocks which are inserted into
@INC don't get treated as strings.
The segfault this uncovered is dealt with in the next email. :)
- Alex
diff -ruN perl-current/lib/lib_pm.PL perl-patched/lib/lib_pm.PL
--- perl-current/lib/lib_pm.PL Wed Feb 26 03:46:16 2003
+++ perl-patched/lib/lib_pm.PL Wed Feb 26 06:05:40 2003
@@ -71,17 +71,19 @@
my %names;
foreach (reverse @_) {
- my $path = $_; # we'll be modifying it, so break the alias
- if ($path eq '') {
+ if (!defined $_ or $_ eq '') {
require Carp;
Carp::carp("Empty compile time value given to use lib");
+ next;
}
+ my $path = $_; # we'll be modifying it, so break the alias
+ unshift(@INC, $path) && next if UNIVERSAL::isa($path,"CODE"); # Skip CODE refs
$path = _nativize($path);
if (-e $path && ! -d _) {
require Carp;
Carp::carp("Parameter to use lib must be directory, not file");
+ next;
}
unshift(@INC, $path);
# Add any previous version directories we found at configure time
@@ -112,11 +114,17 @@
my %names;
foreach (@_) {
- local $_ = _nativize($_);
+ if (!defined $_ or $_ eq '') {
+ require Carp;
+ Carp::carp("Empty compile time value given to use lib");
+ next;
+ }
+ my $path = $_; # we'll be modifying it, so break the alias
+ $path = _nativize($path);
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;
@@ -134,15 +142,15 @@
# 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);
}
--
Networking -- only one letter away from not working.
Thread Next
-
[patch] small lib.pm bufgixes
by Alex Vandiver