On Sat, Dec 10, 2005 at 03:04:09PM -0800, chromatic wrote: > On Sat, 2005-12-10 at 12:52 -1000, Joshua Hoblitt wrote: > > > I think we need to also change Parrot::IO::Directory->relative_path() to > > filter out '' and replace it with '.' or else we'll have to bundle a > > recent version of File::Spec with Parrot, which I'm not too enthusiastic > > about. > > > > A revised patch is attached. I'll commit it in this form unless there > > is an objection. > > Seems reasonable to me, unless curdir() can ever return 0 or undef, and > also fixes my bug #37875.
We could explicitly test if the return eq '' which would let 0 through but it would still filter out undef. I supposed it's possible that the current dir might be named 0. ;) Revised patch is attached. Cheers, -J --
Index: lib/Parrot/IO/Directory.pm
===================================================================
--- lib/Parrot/IO/Directory.pm (revision 10434)
+++ lib/Parrot/IO/Directory.pm (working copy)
@@ -161,7 +161,13 @@
$path = $path->path if ref $path;
- return File::Spec->abs2rel($path, $self->path);
+ my $rel_path = File::Spec->abs2rel($path, $self->path);
+
+ # some (all?) versions of File::Spec->abs2rel() prior to 3.13 return ''
+ # instead of '.' to indicate the current working directory. In order to be
+ # compatible with both pre/post version 3.13 we're normalizing the current
+ # working dir to be '.'.
+ return ($rel_path eq '') ? '.' : $rel_path;
}
=item C<parent()>
Index: t/perl/Parrot_IO.t
===================================================================
--- t/perl/Parrot_IO.t (revision 10434)
+++ t/perl/Parrot_IO.t (working copy)
@@ -97,7 +97,7 @@
ok($f1 && $f2, 'file_with_name');
# Relative paths.
-is($d->relative_path($d->path), '', 'relative_path same dir');
+is($d->relative_path($d->path), curdir(), 'relative_path same dir');
is($d1->relative_path($f1->path), 'file1.txt', 'relative_path same file');
is($d->relative_path($d1->path), 'one', 'relative_path down to dir');
is($d->relative_path($f1->path), catfile(qw(one file1.txt)),
pgpgAEjcK0rAL.pgp
Description: PGP signature
