This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PathTools: use PerlLIO_*() functions and chdir() on a symlink differences
authorTony Cook <tony@develop-help.com>
Wed, 7 Oct 2020 00:50:55 +0000 (11:50 +1100)
committerTony Cook <tony@develop-help.com>
Tue, 1 Dec 2020 04:29:33 +0000 (15:29 +1100)
Use PerlLIO_lstat() and PerlLIO_readlink() instead of directly calling
the POSIX names, so our Win32 overrides work.

For the test, unlike POSIX, changing directory via a symlink on Win32
appears to store the symlink as part of the current directory rather
so GetCurrentDirectory() fetches that rather than the hardlinked path.

13 files changed:
dist/PathTools/Cwd.pm
dist/PathTools/Cwd.xs
dist/PathTools/lib/File/Spec.pm
dist/PathTools/lib/File/Spec/AmigaOS.pm
dist/PathTools/lib/File/Spec/Cygwin.pm
dist/PathTools/lib/File/Spec/Epoc.pm
dist/PathTools/lib/File/Spec/Functions.pm
dist/PathTools/lib/File/Spec/Mac.pm
dist/PathTools/lib/File/Spec/OS2.pm
dist/PathTools/lib/File/Spec/Unix.pm
dist/PathTools/lib/File/Spec/VMS.pm
dist/PathTools/lib/File/Spec/Win32.pm
dist/PathTools/t/cwd.t

index ce0f25f..6a1d2f1 100644 (file)
@@ -3,7 +3,7 @@ use strict;
 use Exporter;
 
 
-our $VERSION = '3.79';
+our $VERSION = '3.80';
 my $xs_version = $VERSION;
 $VERSION =~ tr/_//d;
 
index e7ecb3c..223e1a6 100644 (file)
@@ -84,6 +84,9 @@ bsd_realpath(const char *path, char resolved[MAXPATHLEN])
        unsigned symlinks;
        int serrno;
        char remaining[MAXPATHLEN], next_token[MAXPATHLEN];
+#ifdef PERL_IMPLICIT_SYS
+        dTHX;
+#endif
 
        serrno = errno;
        symlinks = 0;
@@ -175,8 +178,8 @@ bsd_realpath(const char *path, char resolved[MAXPATHLEN])
             }
 #if defined(HAS_LSTAT) && defined(HAS_READLINK) && defined(HAS_SYMLINK)
             {
-                struct stat sb;
-                if (lstat(resolved, &sb) != 0) {
+                Stat_t sb;
+                if (PerlLIO_lstat(resolved, &sb) != 0) {
                     if (errno == ENOENT && p == NULL) {
                         errno = serrno;
                         return (resolved);
@@ -191,7 +194,7 @@ bsd_realpath(const char *path, char resolved[MAXPATHLEN])
                         errno = ELOOP;
                         return (NULL);
                     }
-                    slen = readlink(resolved, symlink, sizeof(symlink) - 1);
+                    slen = PerlLIO_readlink(resolved, symlink, sizeof(symlink) - 1);
                     if (slen < 0)
                         return (NULL);
                     symlink[slen] = '\0';
index 732746d..30d883b 100644 (file)
@@ -2,7 +2,7 @@ package File::Spec;
 
 use strict;
 
-our $VERSION = '3.79';
+our $VERSION = '3.80';
 $VERSION =~ tr/_//d;
 
 my %module = (
index 0d3c9a5..fd9da81 100644 (file)
@@ -3,7 +3,7 @@ package File::Spec::AmigaOS;
 use strict;
 require File::Spec::Unix;
 
-our $VERSION = '3.79';
+our $VERSION = '3.80';
 $VERSION =~ tr/_//d;
 
 our @ISA = qw(File::Spec::Unix);
index 591af63..953c233 100644 (file)
@@ -3,7 +3,7 @@ package File::Spec::Cygwin;
 use strict;
 require File::Spec::Unix;
 
-our $VERSION = '3.79';
+our $VERSION = '3.80';
 $VERSION =~ tr/_//d;
 
 our @ISA = qw(File::Spec::Unix);
index 4b8a17f..fcb9e89 100644 (file)
@@ -2,7 +2,7 @@ package File::Spec::Epoc;
 
 use strict;
 
-our $VERSION = '3.79';
+our $VERSION = '3.80';
 $VERSION =~ tr/_//d;
 
 require File::Spec::Unix;
index fda2e95..e14ad2f 100644 (file)
@@ -3,7 +3,7 @@ package File::Spec::Functions;
 use File::Spec;
 use strict;
 
-our $VERSION = '3.79';
+our $VERSION = '3.80';
 $VERSION =~ tr/_//d;
 
 require Exporter;
index 504d0ce..8026edc 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use Cwd ();
 require File::Spec::Unix;
 
-our $VERSION = '3.79';
+our $VERSION = '3.80';
 $VERSION =~ tr/_//d;
 
 our @ISA = qw(File::Spec::Unix);
index fd7bc7f..3c35ba9 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use Cwd ();
 require File::Spec::Unix;
 
-our $VERSION = '3.79';
+our $VERSION = '3.80';
 $VERSION =~ tr/_//d;
 
 our @ISA = qw(File::Spec::Unix);
index 2221587..c06d18f 100644 (file)
@@ -3,7 +3,7 @@ package File::Spec::Unix;
 use strict;
 use Cwd ();
 
-our $VERSION = '3.79';
+our $VERSION = '3.80';
 $VERSION =~ tr/_//d;
 
 =head1 NAME
index 174dd22..9b78c8b 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use Cwd ();
 require File::Spec::Unix;
 
-our $VERSION = '3.79';
+our $VERSION = '3.80';
 $VERSION =~ tr/_//d;
 
 our @ISA = qw(File::Spec::Unix);
index a3b89c3..1537442 100644 (file)
@@ -5,7 +5,7 @@ use strict;
 use Cwd ();
 require File::Spec::Unix;
 
-our $VERSION = '3.79';
+our $VERSION = '3.80';
 $VERSION =~ tr/_//d;
 
 our @ISA = qw(File::Spec::Unix);
index c056938..d155e33 100644 (file)
@@ -187,6 +187,10 @@ rmtree($test_dirs[0], 0, 0);
 SKIP: {
     skip "no symlinks on this platform", 2+$EXTRA_ABSPATH_TESTS unless $Config{d_symlink} && $^O !~ m!^(qnx|nto)!;
 
+    # on Win32 GetCurrentDirectory() includes the symlink if
+    # you chdir() to a path including the symlink.
+    skip "Win32 symlinks are unusual", 2+$EXTRA_ABSPATH_TESTS if $^O eq "MSWin32";
+
     my $file = "linktest";
     mkpath([$Test_Dir], 0, 0777);
     symlink $Test_Dir, $file;