On Sat, Dec 10, 2005 at 09:07:50PM +0000, Alberto Sim??es wrote: > > > Alberto Simoes via RT wrote: > >We can depend on 3.13 instead of 3.14. > > From File::Spec Changelog: > > > >3.13 Tue Nov 15 23:50:37 CST 2005 > > > >[...] > > > > - abs2rel() used to return the empty string when its two arguments > > were identical, which made no sense. Now it returns > > curdir(). [Spotted by David Golden] > > > >So, maybe we should replace '.' by File::Spec->curdir() but I'm not sure. > > Yep, I think the attached patch makes more sense.
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. 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 ? $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)),
pgplfJPI1vy0u.pgp
Description: PGP signature
