summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Cwd.pm
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-03-10 21:56:14 +0000
committerKarl Berry <karl@freefriends.org>2019-03-10 21:56:14 +0000
commite0a2a718e89f9700d627f1e6a8eea8f21d2fbeb8 (patch)
tree39972f65008b0d70f306a5f976494d29411bc41e /Master/tlpkg/tlperl/lib/Cwd.pm
parentb206fdc77d81ed1600949062f08de5690a4bf66f (diff)
tl19 perl 5.28.1 for Windows, from Siep
git-svn-id: svn://tug.org/texlive/trunk@50322 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/Cwd.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/Cwd.pm86
1 files changed, 27 insertions, 59 deletions
diff --git a/Master/tlpkg/tlperl/lib/Cwd.pm b/Master/tlpkg/tlperl/lib/Cwd.pm
index ce142cfe690..58af9352db3 100644
--- a/Master/tlpkg/tlperl/lib/Cwd.pm
+++ b/Master/tlpkg/tlperl/lib/Cwd.pm
@@ -1,16 +1,16 @@
package Cwd;
use strict;
use Exporter;
-use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION);
-$VERSION = '3.67';
+
+our $VERSION = '3.74';
my $xs_version = $VERSION;
$VERSION =~ tr/_//d;
-@ISA = qw/ Exporter /;
-@EXPORT = qw(cwd getcwd fastcwd fastgetcwd);
+our @ISA = qw/ Exporter /;
+our @EXPORT = qw(cwd getcwd fastcwd fastgetcwd);
push @EXPORT, qw(getdcwd) if $^O eq 'MSWin32';
-@EXPORT_OK = qw(chdir abs_path fast_abs_path realpath fast_realpath);
+our @EXPORT_OK = qw(chdir abs_path fast_abs_path realpath fast_realpath);
# sys_cwd may keep the builtin command
@@ -77,19 +77,9 @@ sub _vms_efs {
# If loading the XS stuff doesn't work, we can fall back to pure perl
-if(! defined &getcwd && defined &DynaLoader::boot_DynaLoader) {
- eval {#eval is questionable since we are handling potential errors like
- #"Cwd object version 3.48 does not match bootstrap parameter 3.50
- #at lib/DynaLoader.pm line 216." by having this eval
- if ( $] >= 5.006 ) {
- require XSLoader;
- XSLoader::load( __PACKAGE__, $xs_version);
- } else {
- require DynaLoader;
- push @ISA, 'DynaLoader';
- __PACKAGE__->bootstrap( $xs_version );
- }
- };
+if(! defined &getcwd && defined &DynaLoader::boot_DynaLoader) { # skipped on miniperl
+ require XSLoader;
+ XSLoader::load( __PACKAGE__, $xs_version);
}
# Big nasty table of function aliases
@@ -145,23 +135,6 @@ my %METHOD_MAP =
realpath => 'fast_abs_path',
},
- epoc =>
- {
- cwd => '_epoc_cwd',
- getcwd => '_epoc_cwd',
- fastgetcwd => '_epoc_cwd',
- fastcwd => '_epoc_cwd',
- abs_path => 'fast_abs_path',
- },
-
- MacOS =>
- {
- getcwd => 'cwd',
- fastgetcwd => 'cwd',
- fastcwd => 'cwd',
- abs_path => 'fast_abs_path',
- },
-
amigaos =>
{
getcwd => '_backtick_pwd',
@@ -254,8 +227,7 @@ unless ($METHOD_MAP{$^O}{cwd} or defined &cwd) {
}
}
- # MacOS has some special magic to make `pwd` work.
- if( $os eq 'MacOS' || $found_pwd_cmd )
+ if( $found_pwd_cmd )
{
*cwd = \&_backtick_pwd;
}
@@ -384,9 +356,6 @@ sub chdir {
if ($^O eq 'VMS') {
return $ENV{'PWD'} = $ENV{'DEFAULT'}
}
- elsif ($^O eq 'MacOS') {
- return $ENV{'PWD'} = cwd();
- }
elsif ($^O eq 'MSWin32') {
$ENV{'PWD'} = $newpwd;
return 1;
@@ -418,8 +387,7 @@ sub _perl_abs_path
unless (@cst = stat( $start ))
{
- _carp("stat($start): $!");
- return '';
+ return undef;
}
unless (-d _) {
@@ -453,15 +421,14 @@ sub _perl_abs_path
local *PARENT;
unless (opendir(PARENT, $dotdots))
{
- # probably a permissions issue. Try the native command.
- require File::Spec;
- return File::Spec->rel2abs( $start, _backtick_pwd() );
+ return undef;
}
unless (@cst = stat($dotdots))
{
- _carp("stat($dotdots): $!");
+ my $e = $!;
closedir(PARENT);
- return '';
+ $! = $e;
+ return undef;
}
if ($pst[0] == $cst[0] && $pst[1] == $cst[1])
{
@@ -473,9 +440,10 @@ sub _perl_abs_path
{
unless (defined ($dir = readdir(PARENT)))
{
- _carp("readdir($dotdots): $!");
closedir(PARENT);
- return '';
+ require Errno;
+ $! = Errno::ENOENT();
+ return undef;
}
$tst[0] = $pst[0]+1 unless (@tst = lstat("$dotdots/$dir"))
}
@@ -494,6 +462,7 @@ my $Curdir;
sub fast_abs_path {
local $ENV{PWD} = $ENV{PWD} || ''; # Guard against clobberage
my $cwd = getcwd();
+ defined $cwd or return undef;
require File::Spec;
my $path = @_ ? shift : ($Curdir ||= File::Spec->curdir);
@@ -503,7 +472,9 @@ sub fast_abs_path {
($cwd) = $cwd =~ /(.*)/s;
unless (-e $path) {
- _croak("$path: No such file or directory");
+ require Errno;
+ $! = Errno::ENOENT();
+ return undef;
}
unless (-d _) {
@@ -514,7 +485,7 @@ sub fast_abs_path {
if (-l $path) {
my $link_target = readlink($path);
- die "Can't resolve link $path: $!" unless defined $link_target;
+ defined $link_target or return undef;
$link_target = File::Spec->catpath($vol, $dir, $link_target)
unless File::Spec->file_name_is_absolute($link_target);
@@ -528,7 +499,7 @@ sub fast_abs_path {
}
if (!CORE::chdir($path)) {
- _croak("Cannot chdir to $path: $!");
+ return undef;
}
my $realpath = getcwd();
if (! ((-d $cwd) && (CORE::chdir($cwd)))) {
@@ -676,11 +647,6 @@ sub _qnx_abs_path {
return $realpath;
}
-sub _epoc_cwd {
- return $ENV{'PWD'} = EPOC::getcwd();
-}
-
-
# Now that all the base-level functions are set up, alias the
# user-level functions to the right places
@@ -737,7 +703,8 @@ absolute path of the current working directory.
my $cwd = getcwd();
-Returns the current working directory.
+Returns the current working directory. On error returns C<undef>,
+with C<$!> set to indicate the error.
Exposes the POSIX function getcwd(3) or re-implements it if it's not
available.
@@ -800,7 +767,8 @@ given they'll use the current working directory.
Uses the same algorithm as getcwd(). Symbolic links and relative-path
components ("." and "..") are resolved to return the canonical
-pathname, just like realpath(3).
+pathname, just like realpath(3). On error returns C<undef>, with C<$!>
+set to indicate the error.
=item realpath