perl-PathTools/backport-update-PathTools-to-3.89-from-perl-5.38.0-tag.patch
2023-07-31 20:58:35 +08:00

543 lines
16 KiB
Diff

From aed8b9644ae079731ebb826cfde94e9ddcc97eca Mon Sep 17 00:00:00 2001
From: yangmingtai <yangmingtai@huawei.com>
Date: Mon, 31 Jul 2023 15:08:38 +0800
Subject: [PATCH] update PathTools to 3.89 from perl-5.38.0 tag
The current version of perl-PathTools is 3.80, and this patch upgrades the version to 3.89.
The patch content comes from the release version of perl-5.38.0.
The steps for generating patches are as follows
1.generate perl-PathTools src directory: rpmbuild -bp perl-PathTools.spec
2.tar xf perl-5.38.0.tar.xz
3.compare the dist/PathTools/ directory of perl-5.38.0 and perl-PathTools src directory
---
Changes | 54 ++++++++++++++++++++++++++++++++++++++
Cwd.pm | 51 +++++++++++++----------------------
Cwd.xs | 20 ++++++++------
META.json | 2 +-
META.yml | 2 +-
Makefile.PL | 7 ++---
lib/File/Spec.pm | 8 +++---
lib/File/Spec/AmigaOS.pm | 2 +-
lib/File/Spec/Cygwin.pm | 2 +-
lib/File/Spec/Epoc.pm | 2 +-
lib/File/Spec/Functions.pm | 2 +-
lib/File/Spec/Mac.pm | 2 +-
lib/File/Spec/OS2.pm | 2 +-
lib/File/Spec/Unix.pm | 4 +--
lib/File/Spec/VMS.pm | 2 +-
lib/File/Spec/Win32.pm | 2 +-
t/cwd_enoent.t | 7 ++++-
t/tmpdir.t | 2 +-
18 files changed, 109 insertions(+), 64 deletions(-)
diff --git a/Changes b/Changes
index 7f04db2..47e172a 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,59 @@
Revision history for Perl distribution PathTools.
+3.87-3.88
+
+- Fix handling of empty path, VMS fixes.
+
+3.86
+
+- Fix compilation warning on illumos based platforms
+
+3.85
+
+- Fix issue related to tainting empty PATH
+
+3.84
+
+- Add PerlIO_readlink backcompat defines to Cws.xs
+
+3.83
+
+- More bugtracker changes, document maintainer is the Perl-5 Porters
+
+3.82
+
+- Change to build so bugreports go to GitHub
+
+3.81
+
+- compare inode numbers as strings (github #18788)
+
+3.80
+
+- use the PerlLIO_*() functions for lstat() and readlink() to support
+ Win32 symlink support added to perl.
+
+- skip a test that assumes getcwd() doesn't return symlinks on Win32, where
+ it can.
+
+3.79
+
+- fix an off-by-one in bsd_realpath()
+
+3.78
+
+- fallback to Internals::getcwd() for getcwd() if available (requires
+ $Config{d_getcwd})
+
+3.77
+
+- don't translate "..." to "..\.." on Win32
+
+3.76
+
+- test t/cwd_enoent.t - also accept ESTALE for a directory that no
+ longer exists (github #16699)
+
3.75
- Fix t/abs2rel.t on 5.8.8 by changing mkpath call to be
compatible with older File::Path
diff --git a/Cwd.pm b/Cwd.pm
index 6a1d2f1..dbf08a6 100644
--- a/Cwd.pm
+++ b/Cwd.pm
@@ -3,7 +3,7 @@ use strict;
use Exporter;
-our $VERSION = '3.80';
+our $VERSION = '3.89';
my $xs_version = $VERSION;
$VERSION =~ tr/_//d;
@@ -181,12 +181,6 @@ if ($^O =~ /android/) {
}
my $found_pwd_cmd = defined($pwd_cmd);
-unless ($pwd_cmd) {
- # Isn't this wrong? _backtick_pwd() will fail if someone has
- # pwd in their path but it is not /bin/pwd or /usr/bin/pwd?
- # See [perl #16774]. --jhi
- $pwd_cmd = 'pwd';
-}
# Lazy-load Carp
sub _carp { require Carp; Carp::carp(@_) }
@@ -198,8 +192,14 @@ sub _backtick_pwd {
# Localize %ENV entries in a way that won't create new hash keys.
# Under AmigaOS we don't want to localize as it stops perl from
# finding 'sh' in the PATH.
- my @localize = grep exists $ENV{$_}, qw(PATH IFS CDPATH ENV BASH_ENV) if $^O ne "amigaos";
+ my @localize = grep exists $ENV{$_}, qw(IFS CDPATH ENV BASH_ENV) if $^O ne "amigaos";
local @ENV{@localize} if @localize;
+ # empty PATH is the same as "." on *nix, so localize it to /something/
+ # we won't *use* the path as code above turns $pwd_cmd into a specific
+ # executable, but it will blow up anyway under taint. We could set it to
+ # anything absolute. Perhaps "/" would be better.
+ local $ENV{PATH}= "/usr/bin"
+ if $^O ne "amigaos";
my $cwd = `$pwd_cmd`;
# Belt-and-suspenders in case someone said "undef $/".
@@ -213,26 +213,13 @@ sub _backtick_pwd {
# we take care not to override an existing definition for cwd().
unless ($METHOD_MAP{$^O}{cwd} or defined &cwd) {
- # The pwd command is not available in some chroot(2)'ed environments
- my $sep = $Config::Config{path_sep} || ':';
- my $os = $^O; # Protect $^O from tainting
-
-
- # Try again to find a pwd, this time searching the whole PATH.
- if (defined $ENV{PATH} and $os ne 'MSWin32') { # no pwd on Windows
- my @candidates = split($sep, $ENV{PATH});
- while (!$found_pwd_cmd and @candidates) {
- my $candidate = shift @candidates;
- $found_pwd_cmd = 1 if -x "$candidate/pwd";
- }
- }
-
if( $found_pwd_cmd )
{
*cwd = \&_backtick_pwd;
}
else {
- *cwd = \&getcwd;
+ # getcwd() might have an empty prototype
+ *cwd = sub { getcwd(); };
}
}
@@ -275,7 +262,7 @@ sub fastcwd_ {
($odev, $oino) = ($cdev, $cino);
CORE::chdir('..') || return undef;
($cdev, $cino) = stat('.');
- last if $odev == $cdev && $oino == $cino;
+ last if $odev == $cdev && $oino eq $cino;
opendir(DIR, '.') || return undef;
for (;;) {
$direntry = readdir(DIR);
@@ -284,7 +271,7 @@ sub fastcwd_ {
next if $direntry eq '..';
($tdev, $tino) = lstat($direntry);
- last unless $tdev != $odev || $tino != $oino;
+ last unless $tdev != $odev || $tino ne $oino;
}
closedir(DIR);
return undef unless defined $direntry; # should never happen
@@ -298,7 +285,7 @@ sub fastcwd_ {
&& CORE::chdir($1) or return undef;
($cdev, $cino) = stat('.');
die "Unstable directory path, current directory changed unexpectedly"
- if $cdev != $orig_cdev || $cino != $orig_cino;
+ if $cdev != $orig_cdev || $cino ne $orig_cino;
$path;
}
if (not defined &fastcwd) { *fastcwd = \&fastcwd_ }
@@ -315,7 +302,7 @@ sub chdir_init {
if ($ENV{'PWD'} and $^O ne 'os2' and $^O ne 'dos' and $^O ne 'MSWin32') {
my($dd,$di) = stat('.');
my($pd,$pi) = stat($ENV{'PWD'});
- if (!defined $dd or !defined $pd or $di != $pi or $dd != $pd) {
+ if (!defined $dd or !defined $pd or $di ne $pi or $dd != $pd) {
$ENV{'PWD'} = cwd();
}
}
@@ -328,7 +315,7 @@ sub chdir_init {
if ($^O ne 'MSWin32' and $ENV{'PWD'} =~ m|(/[^/]+(/[^/]+/[^/]+))(.*)|s) {
my($pd,$pi) = stat($2);
my($dd,$di) = stat($1);
- if (defined $pd and defined $dd and $di == $pi and $dd == $pd) {
+ if (defined $pd and defined $dd and $di ne $pi and $dd == $pd) {
$ENV{'PWD'}="$2$3";
}
}
@@ -430,7 +417,7 @@ sub _perl_abs_path
$! = $e;
return undef;
}
- if ($pst[0] == $cst[0] && $pst[1] == $cst[1])
+ if ($pst[0] == $cst[0] && $pst[1] eq $cst[1])
{
$dir = undef;
}
@@ -448,7 +435,7 @@ sub _perl_abs_path
$tst[0] = $pst[0]+1 unless (@tst = lstat("$dotdots/$dir"))
}
while ($dir eq '.' || $dir eq '..' || $tst[0] != $pst[0] ||
- $tst[1] != $pst[1]);
+ $tst[1] ne $pst[1]);
}
$cwd = (defined $dir ? "$dir" : "" ) . "/$cwd" ;
closedir(PARENT);
@@ -820,9 +807,7 @@ C<fast_abs_path()>.
=head1 AUTHOR
-Originally by the perl5-porters.
-
-Maintained by Ken Williams <KWILLIAMS@cpan.org>
+Maintained by perl5-porters <F<perl5-porters@perl.org>>.
=head1 COPYRIGHT
diff --git a/Cwd.xs b/Cwd.xs
index 223e1a6..ca8639d 100644
--- a/Cwd.xs
+++ b/Cwd.xs
@@ -7,12 +7,14 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
-#ifndef NO_PPPORT_H
-# define NEED_croak_xs_usage
-# define NEED_sv_2pv_flags
-# define NEED_my_strlcpy
-# define NEED_my_strlcat
-# include "ppport.h"
+#define NEED_croak_xs_usage
+#define NEED_sv_2pv_flags
+#define NEED_my_strlcpy
+#define NEED_my_strlcat
+#include "ppport.h"
+
+#if defined(HAS_READLINK) && !defined(PerlLIO_readlink)
+#define PerlLIO_readlink readlink
#endif
#ifdef I_UNISTD
@@ -20,8 +22,10 @@
#endif
/* For special handling of os390 sysplexed systems */
+#ifdef OS390
#define SYSNAME "$SYSNAME"
#define SYSNAME_LEN (sizeof(SYSNAME) - 1)
+#endif
/* The realpath() implementation from OpenBSD 3.9 to 4.2 (realpath.c 1.13)
* Renamed here to bsd_realpath() to avoid library conflicts.
@@ -198,7 +202,7 @@ bsd_realpath(const char *path, char resolved[MAXPATHLEN])
if (slen < 0)
return (NULL);
symlink[slen] = '\0';
-# ifdef EBCDIC /* XXX Probably this should be only os390 */
+# ifdef OS390
/* Replace all instances of $SYSNAME/foo simply by /foo */
if (slen > SYSNAME_LEN + strlen(next_token)
&& strnEQ(symlink, SYSNAME, SYSNAME_LEN)
@@ -241,7 +245,7 @@ bsd_realpath(const char *path, char resolved[MAXPATHLEN])
}
remaining_len = my_strlcpy(remaining, symlink, sizeof(remaining));
}
-# ifdef EBCDIC
+# ifdef OS390
not_symlink: ;
# endif
}
diff --git a/META.json b/META.json
index ad429a5..d810ba7 100644
--- a/META.json
+++ b/META.json
@@ -50,6 +50,6 @@
"url" : "git://perl5.git.perl.org/perl.git"
}
},
- "version" : "3.73",
+ "version" : "3.86",
"x_serialization_backend" : "JSON::PP version 2.27400_02"
}
diff --git a/META.yml b/META.yml
index c2adfcf..f5e9fe3 100644
--- a/META.yml
+++ b/META.yml
@@ -26,5 +26,5 @@ resources:
bugtracker: https://rt.perl.org/rt3/
homepage: http://dev.perl.org/
repository: git://perl5.git.perl.org/perl.git
-version: '3.73'
+version: '3.86'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff --git a/Makefile.PL b/Makefile.PL
index 11e04af..754acbe 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -16,7 +16,7 @@ push @extra, 'LICENSE' => 'perl_5'
push @extra, 'META_MERGE' => {
resources => {
repository => 'git://perl5.git.perl.org/perl.git',
- bugtracker => 'https://rt.perl.org/rt3/',
+ bugtracker => 'https://github.com/Perl/perl5/issues',
homepage => "http://dev.perl.org/",
license => [ 'http://dev.perl.org/licenses/' ],
},
@@ -29,10 +29,7 @@ WriteMakefile
'VERSION_FROM' => 'Cwd.pm',
'ABSTRACT' => 'Tools for working with directory and file names',
'AUTHOR' => 'Perl 5 Porters',
- 'DEFINE' => join(" ",
- "-DDOUBLE_SLASHES_SPECIAL=@{[$^O eq q(qnx) || $^O eq q(nto) ? 1 : 0]}",
- ((grep { $_ eq 'PERL_CORE=1' } @ARGV) ? '-DNO_PPPORT_H' : ()),
- ),
+ 'DEFINE' => "-DDOUBLE_SLASHES_SPECIAL=@{[$^O eq q(qnx) || $^O eq q(nto) ? 1 : 0]}",
'PREREQ_PM' => {
'Carp' => '0',
'File::Basename' => '0',
diff --git a/lib/File/Spec.pm b/lib/File/Spec.pm
index 30d883b..fc10c0f 100644
--- a/lib/File/Spec.pm
+++ b/lib/File/Spec.pm
@@ -2,7 +2,7 @@ package File::Spec;
use strict;
-our $VERSION = '3.80';
+our $VERSION = '3.88';
$VERSION =~ tr/_//d;
my %module = (
@@ -33,13 +33,13 @@ File::Spec - portably perform operations on file names
use File::Spec;
- $x=File::Spec->catfile('a', 'b', 'c');
+ my $x = File::Spec->catfile('a', 'b', 'c');
which returns 'a/b/c' under Unix. Or:
use File::Spec::Functions;
- $x = catfile('a', 'b', 'c');
+ my $x = catfile('a', 'b', 'c');
=head1 DESCRIPTION
@@ -316,7 +316,7 @@ L<ExtUtils::MakeMaker>
=head1 AUTHOR
-Currently maintained by Ken Williams C<< <KWILLIAMS@cpan.org> >>.
+Maintained by perl5-porters <F<perl5-porters@perl.org>>.
The vast majority of the code was written by
Kenneth Albanowski C<< <kjahds@kjahds.com> >>,
diff --git a/lib/File/Spec/AmigaOS.pm b/lib/File/Spec/AmigaOS.pm
index fd9da81..3fc3c98 100644
--- a/lib/File/Spec/AmigaOS.pm
+++ b/lib/File/Spec/AmigaOS.pm
@@ -3,7 +3,7 @@ package File::Spec::AmigaOS;
use strict;
require File::Spec::Unix;
-our $VERSION = '3.80';
+our $VERSION = '3.88';
$VERSION =~ tr/_//d;
our @ISA = qw(File::Spec::Unix);
diff --git a/lib/File/Spec/Cygwin.pm b/lib/File/Spec/Cygwin.pm
index 953c233..fb3eaaa 100644
--- a/lib/File/Spec/Cygwin.pm
+++ b/lib/File/Spec/Cygwin.pm
@@ -3,7 +3,7 @@ package File::Spec::Cygwin;
use strict;
require File::Spec::Unix;
-our $VERSION = '3.80';
+our $VERSION = '3.88';
$VERSION =~ tr/_//d;
our @ISA = qw(File::Spec::Unix);
diff --git a/lib/File/Spec/Epoc.pm b/lib/File/Spec/Epoc.pm
index fcb9e89..9391f3a 100644
--- a/lib/File/Spec/Epoc.pm
+++ b/lib/File/Spec/Epoc.pm
@@ -2,7 +2,7 @@ package File::Spec::Epoc;
use strict;
-our $VERSION = '3.80';
+our $VERSION = '3.88';
$VERSION =~ tr/_//d;
require File::Spec::Unix;
diff --git a/lib/File/Spec/Functions.pm b/lib/File/Spec/Functions.pm
index e14ad2f..a0d8641 100644
--- a/lib/File/Spec/Functions.pm
+++ b/lib/File/Spec/Functions.pm
@@ -3,7 +3,7 @@ package File::Spec::Functions;
use File::Spec;
use strict;
-our $VERSION = '3.80';
+our $VERSION = '3.88';
$VERSION =~ tr/_//d;
require Exporter;
diff --git a/lib/File/Spec/Mac.pm b/lib/File/Spec/Mac.pm
index 8026edc..5f5cca9 100644
--- a/lib/File/Spec/Mac.pm
+++ b/lib/File/Spec/Mac.pm
@@ -4,7 +4,7 @@ use strict;
use Cwd ();
require File::Spec::Unix;
-our $VERSION = '3.80';
+our $VERSION = '3.88';
$VERSION =~ tr/_//d;
our @ISA = qw(File::Spec::Unix);
diff --git a/lib/File/Spec/OS2.pm b/lib/File/Spec/OS2.pm
index 3c35ba9..eea5328 100644
--- a/lib/File/Spec/OS2.pm
+++ b/lib/File/Spec/OS2.pm
@@ -4,7 +4,7 @@ use strict;
use Cwd ();
require File::Spec::Unix;
-our $VERSION = '3.80';
+our $VERSION = '3.88';
$VERSION =~ tr/_//d;
our @ISA = qw(File::Spec::Unix);
diff --git a/lib/File/Spec/Unix.pm b/lib/File/Spec/Unix.pm
index c06d18f..2d5af10 100644
--- a/lib/File/Spec/Unix.pm
+++ b/lib/File/Spec/Unix.pm
@@ -3,7 +3,7 @@ package File::Spec::Unix;
use strict;
use Cwd ();
-our $VERSION = '3.80';
+our $VERSION = '3.88';
$VERSION =~ tr/_//d;
=head1 NAME
@@ -530,7 +530,7 @@ Copyright (c) 2004 by the Perl 5 Porters. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
-Please submit bug reports and patches to perlbug@perl.org.
+Please submit bug reports at L<https://github.com/Perl/perl5/issues>.
=head1 SEE ALSO
diff --git a/lib/File/Spec/VMS.pm b/lib/File/Spec/VMS.pm
index a99b4a4..e5d5a38 100644
--- a/lib/File/Spec/VMS.pm
+++ b/lib/File/Spec/VMS.pm
@@ -4,7 +4,7 @@ use strict;
use Cwd ();
require File::Spec::Unix;
-our $VERSION = '3.75';
+our $VERSION = '3.88';
$VERSION =~ tr/_//d;
our @ISA = qw(File::Spec::Unix);
diff --git a/lib/File/Spec/Win32.pm b/lib/File/Spec/Win32.pm
index 1537442..292c2f8 100644
--- a/lib/File/Spec/Win32.pm
+++ b/lib/File/Spec/Win32.pm
@@ -5,7 +5,7 @@ use strict;
use Cwd ();
require File::Spec::Unix;
-our $VERSION = '3.80';
+our $VERSION = '3.88';
$VERSION =~ tr/_//d;
our @ISA = qw(File::Spec::Unix);
diff --git a/t/cwd_enoent.t b/t/cwd_enoent.t
index 2e94bad..05b30b3 100644
--- a/t/cwd_enoent.t
+++ b/t/cwd_enoent.t
@@ -28,8 +28,13 @@ foreach my $type (qw(regular perl)) {
# https://github.com/Perl/perl5/issues/16525
# https://bugs.dragonflybsd.org/issues/3250
+ my @vlist = ($Config{osvers} =~ /(\d+)/g);
+ my $osver = sprintf("%d%03d", map { defined() ? $_ : '0' } @vlist[0,1]);
skip "getcwd() doesn't fail on non-existent directories on this platform", 4
- if $type eq 'regular' && $^O eq 'dragonfly';
+ if $type eq 'regular' && $^O eq 'dragonfly' && $osver < 6002;
+
+ skip "getcwd() doesn't fail on non-existent directories on this platform", 4
+ if $type eq 'regular' && $^O eq 'haiku';
no warnings "redefine";
local *Cwd::abs_path = \&Cwd::_perl_abs_path if $type eq "perl";
diff --git a/t/tmpdir.t b/t/tmpdir.t
index 0f03dc5..aeff4fc 100644
--- a/t/tmpdir.t
+++ b/t/tmpdir.t
@@ -43,7 +43,7 @@ for ('File::Spec', "File::Spec::Win32") {
-d $ENV{TMPDIR} && -w _
or skip "Can't create usable TMPDIR env var", 1;
my $tmpdir2 = $_->tmpdir;
- isn't $tmpdir2, $tmpdir1, "$_->tmpdir works with changing env";
+ isnt $tmpdir2, $tmpdir1, "$_->tmpdir works with changing env";
}
}
--
2.27.0