« /usr/local/lib/perl5/5.44.0/x86_64-linux/Time/HiRes.pm
↑ Summary
/usr/local/lib/perl5/5.44.0/vars.pm »
| 1 | package Cwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | use Exporter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | our $VERSION = '3.95'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | my $xs_version = $VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | $VERSION =~ tr/_//d; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | our @ISA = qw/ Exporter /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | our @EXPORT = qw(cwd getcwd fastcwd fastgetcwd); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | push @EXPORT, qw(getdcwd) if $^O eq 'MSWin32'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | our @EXPORT_OK = qw(chdir abs_path fast_abs_path realpath fast_realpath); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # sys_cwd may keep the builtin command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # All the functionality of this module may provided by builtins, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # there is no sense to process the rest of the file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # The best choice may be to have this in BEGIN, but how to return from BEGIN? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | if ($^O eq 'os2') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | local $^W = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | *cwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | *getcwd = \&cwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | *fastgetcwd = \&cwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | *fastcwd = \&cwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | *fast_abs_path = \&sys_abspath if defined &sys_abspath; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | *abs_path = \&fast_abs_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | *realpath = \&fast_abs_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | *fast_realpath = \&fast_abs_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # Need to look up the feature settings on VMS. The preferred way is to use the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # VMS::Feature module, but that may not be available to dual life modules. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | my $use_vms_feature; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | if ($^O eq 'VMS') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | if (eval { local $SIG{__DIE__}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | local @INC = @INC; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | pop @INC if $INC[-1] eq '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | require VMS::Feature; }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | $use_vms_feature = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # Need to look up the UNIX report mode. This may become a dynamic mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # in the future. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | sub _vms_unix_rpt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my $unix_rpt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vms_unix_rpt: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if ($use_vms_feature) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $unix_rpt = VMS::Feature::current("filename_unix_report"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | my $env_unix_rpt = $ENV{'DECC$FILENAME_UNIX_REPORT'} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'DECC$FILENAME_UNIX_REPORT'} || ''
MC/DC0%0/1
$ENV{'DECC$FILENAME_UNIX_REPORT'} || ''
$ENV{'DECC$FILENAME_UNIX_REPORT'}
Truth table0%0/2
A
A= $ENV{'DECC$FILENAME_UNIX_REPORT'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $unix_rpt = $env_unix_rpt =~ /^[ET1]/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | return $unix_rpt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # Need to look up the EFS character set mode. This may become a dynamic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # mode in the future. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | sub _vms_efs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my $efs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vms_efs: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ($use_vms_feature) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $efs = VMS::Feature::current("efs_charset"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | my $env_efs = $ENV{'DECC$EFS_CHARSET'} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'DECC$EFS_CHARSET'} || ''
MC/DC0%0/1
$ENV{'DECC$EFS_CHARSET'} || ''
$ENV{'DECC$EFS_CHARSET'}
Truth table0%0/2
A
A= $ENV{'DECC$EFS_CHARSET'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $efs = $env_efs =~ /^[ET1]/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return $efs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # If loading the XS stuff doesn't work, we can fall back to pure perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | if(! defined &getcwd && defined &DynaLoader::boot_DynaLoader) { # skipped on miniperl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | require XSLoader; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | XSLoader::load( __PACKAGE__, $xs_version); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # Big nasty table of function aliases | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | my %METHOD_MAP = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | VMS => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | cwd => '_vms_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | getcwd => '_vms_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | fastcwd => '_vms_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | fastgetcwd => '_vms_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | abs_path => '_vms_abs_path', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | fast_abs_path => '_vms_abs_path', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | MSWin32 => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # We assume that &_NT_cwd is defined as an XSUB or in the core. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | cwd => '_NT_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | getcwd => '_NT_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | fastcwd => '_NT_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | fastgetcwd => '_NT_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | abs_path => 'fast_abs_path', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | realpath => 'fast_abs_path', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | dos => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | cwd => '_dos_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | getcwd => '_dos_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | fastgetcwd => '_dos_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | fastcwd => '_dos_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | abs_path => 'fast_abs_path', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # QNX4. QNX6 has a $os of 'nto'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | qnx => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | cwd => '_qnx_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | getcwd => '_qnx_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | fastgetcwd => '_qnx_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | fastcwd => '_qnx_cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | abs_path => '_qnx_abs_path', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | fast_abs_path => '_qnx_abs_path', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | cygwin => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | getcwd => 'cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | fastgetcwd => 'cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | fastcwd => 'cwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | abs_path => 'fast_abs_path', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | realpath => 'fast_abs_path', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | amigaos => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | getcwd => '_backtick_pwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | fastgetcwd => '_backtick_pwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | fastcwd => '_backtick_pwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | abs_path => 'fast_abs_path', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | $METHOD_MAP{NT} = $METHOD_MAP{MSWin32}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # Find the pwd command in the expected locations. We assume these | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # are safe. This prevents _backtick_pwd() consulting $ENV{PATH} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # so everything works under taint mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | my $pwd_cmd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | if($^O ne 'MSWin32') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | foreach my $try ('/bin/pwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | '/usr/bin/pwd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | '/QOpenSys/bin/pwd', # OS/400 PASE. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | if( -x $try ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | $pwd_cmd = $try; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # Android has a built-in pwd. Using $pwd_cmd will DTRT if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # this perl was compiled with -Dd_useshellcmds, which is the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # default for Android, but the block below is needed for the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # miniperl running on the host when cross-compiling, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # potentially for native builds with -Ud_useshellcmds. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | if ($^O =~ /android/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # If targetsh is executable, then we're either a full | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # perl, or a miniperl for a native build. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | if ( exists($Config::Config{targetsh}) && -x $Config::Config{targetsh}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | $pwd_cmd = "$Config::Config{targetsh} -c pwd" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | my $sh = $Config::Config{sh} || (-x '/system/bin/sh' ? '/system/bin/sh' : 'sh'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | $pwd_cmd = "$sh -c pwd" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | my $found_pwd_cmd = defined($pwd_cmd); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # Lazy-load Carp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub _carp { require Carp; Carp::carp(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_carp: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub _croak { require Carp; Carp::croak(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_croak: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # The 'natural and safe form' for UNIX (pwd may be setuid root) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | sub _backtick_pwd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # Localize %ENV entries in a way that won't create new hash keys. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # Under AmigaOS we don't want to localize as it stops perl from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # finding 'sh' in the PATH. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | my @localize = grep exists $ENV{$_}, qw(IFS CDPATH ENV BASH_ENV) if $^O ne "amigaos"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_backtick_pwd: not called CC=5 SCAR=34.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | local @ENV{@localize} if @localize; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # empty PATH is the same as "." on *nix, so localize it to /something/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # we won't *use* the path as code above turns $pwd_cmd into a specific | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # executable, but it will blow up anyway under taint. We could set it to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # anything absolute. Perhaps "/" would be better. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | local $ENV{PATH}= "/usr/bin" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | if $^O ne "amigaos"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $cwd = `$pwd_cmd`; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # Belt-and-suspenders in case someone said "undef $/". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | local $/ = "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # `pwd` may fail e.g. if the disk is full | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | chomp($cwd) if defined $cwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $cwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # Since some ports may predefine cwd internally (e.g., NT) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # we take care not to override an existing definition for cwd(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | unless ($METHOD_MAP{$^O}{cwd} or defined &cwd) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | if( $found_pwd_cmd ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | *cwd = \&_backtick_pwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # getcwd() might have an empty prototype | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | *cwd = sub { getcwd(); }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | if ($^O eq 'cygwin') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # We need to make sure cwd() is called with no args, because it's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # got an arg-less prototype and will die if args are present. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | local $^W = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | my $orig_cwd = \&cwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | *cwd = sub { &$orig_cwd() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # set a reasonable (and very safe) default for fastgetcwd, in case it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # isn't redefined later (20001212 rspier) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | *fastgetcwd = \&cwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | # A non-XS version of getcwd() - also used to bootstrap the perl build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # process, when miniperl is running and no XS loading happens. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | sub _perl_getcwd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | abs_path('.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_perl_getcwd: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # By John Bazik | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # Usage: $cwd = &fastcwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # This is a faster version of getcwd. It's also more dangerous because | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # you might chdir out of a directory that you can't chdir back into. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | sub fastcwd_ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | my($odev, $oino, $cdev, $cino, $tdev, $tino); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fastcwd_: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my(@path, $path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | local(*DIR); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my($orig_cdev, $orig_cino) = stat('.'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ($cdev, $cino) = ($orig_cdev, $orig_cino); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | for (;;) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my $direntry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ($odev, $oino) = ($cdev, $cino); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | CORE::chdir('..') || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ($cdev, $cino) = stat('.'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | last if $odev == $cdev && $oino eq $cino; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$odev == $cdev and $oino eq $cino
MC/DC0%0/2
$odev == $cdev and $oino eq $cino
$odev == $cdev
$oino eq $cino
Truth table0%0/3
A and B
A= $odev == $cdevB= $oino eq $cino
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | opendir(DIR, '.') || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | for (;;) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $direntry = readdir(DIR); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | last unless defined $direntry; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | next if $direntry eq '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | next if $direntry eq '..'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ($tdev, $tino) = lstat($direntry); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | last unless $tdev != $odev || $tino ne $oino; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tdev != $odev or $tino ne $oino
MC/DC0%0/2
$tdev != $odev or $tino ne $oino
$tdev != $odev
$tino ne $oino
Truth table0%0/3
A or B
A= $tdev != $odevB= $tino ne $oino
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | closedir(DIR); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | return undef unless defined $direntry; # should never happen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | unshift(@path, $direntry); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $path = '/' . join('/', @path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | if ($^O eq 'apollo') { $path = "/".$path; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | # At this point $path may be tainted (if tainting) and chdir would fail. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # Untaint it then check that we landed where we started. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | $path =~ /^(.*)\z/s # untaint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$path =~ /^(.*)\z/s and CORE::chdir $1
MC/DC0%0/2
$path =~ /^(.*)\z/s and CORE::chdir $1
$path =~ /^(.*)\z/s
CORE::chdir $1
Truth table0%0/3
A and B
A= $path =~ /^(.*)\z/sB= CORE::chdir $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | && CORE::chdir($1) or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ($cdev, $cino) = stat('.'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | die "Unstable directory path, current directory changed unexpectedly" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$cdev != $orig_cdev or $cino ne $orig_cino
MC/DC0%0/2
$cdev != $orig_cdev or $cino ne $orig_cino
$cdev != $orig_cdev
$cino ne $orig_cino
Truth table0%0/3
A or B
A= $cdev != $orig_cdevB= $cino ne $orig_cino
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | if $cdev != $orig_cdev || $cino ne $orig_cino; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | if (not defined &fastcwd) { *fastcwd = \&fastcwd_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | # Keeps track of current working directory in PWD environment var | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # Usage: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # use Cwd 'chdir'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # chdir $newdir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | my $chdir_init = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | sub chdir_init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | if ($ENV{'PWD'} and $^O ne 'os2' and $^O ne 'dos' and $^O ne 'MSWin32') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chdir_init: not called CC=16 SCAR=56.1
Pod
undocumented
Branch: 1 branch
Condition0%0/9
$ENV{"PWD"} and $^O ne "os2" and $^O ne "dos" and $^O ne "MSWin32"
$ENV{"PWD"} and $^O ne "os2" and $^O ne "dos"
$ENV{"PWD"} and $^O ne "os2"
MC/DC0%0/4
$ENV{"PWD"} and $^O ne "os2" and $^O ne "dos" and $^O ne "MSWin32"
$ENV{"PWD"}
$^O ne "os2"
$^O ne "dos"
$^O ne "MSWin32"
Truth table0%0/5
A and B and C and D
A= $ENV{"PWD"}B= $^O ne "os2"C= $^O ne "dos"D= $^O ne "MSWin32"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my($dd,$di) = stat('.'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my($pd,$pi) = stat($ENV{'PWD'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if (!defined $dd or !defined $pd or $di ne $pi or $dd != $pd) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
not defined $dd && defined $pd or $di ne $pi or $dd != $pd
not defined $dd && defined $pd or $di ne $pi
defined $dd && defined $pd
MC/DC0%0/4
not defined $dd && defined $pd or $di ne $pi or $dd != $pd
defined $dd
defined $pd
$di ne $pi
$dd != $pd
Truth table0%0/5
not(A && B) or C or D
A= defined $ddB= defined $pdC= $di ne $piD= $dd != $pd
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $ENV{'PWD'} = cwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my $wd = cwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | $wd = Win32::GetFullPathName($wd) if $^O eq 'MSWin32'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $ENV{'PWD'} = $wd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # Strip an automounter prefix (where /tmp_mnt/foo/bar == /foo/bar) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | if ($^O ne 'MSWin32' and $ENV{'PWD'} =~ m|(/[^/]+(/[^/]+/[^/]+))(.*)|s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$^O ne "MSWin32" and $ENV{"PWD"} =~ m[(/[^/]+(/[^/]+/[^/]+))(.*)]s
MC/DC0%0/2
$^O ne "MSWin32" and $ENV{"PWD"} =~ m[(/[^/]+(/[^/]+/[^/]+))(.*)]s
$^O ne "MSWin32"
$ENV{"PWD"} =~ m[(/[^/]+(/[^/]+/[^/]+))(.*)]s
Truth table0%0/3
A and B
A= $^O ne "MSWin32"B= $ENV{"PWD"} =~ m[(/[^/]+(/[^/]+/[^/]+))(.*)]s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my($pd,$pi) = stat($2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my($dd,$di) = stat($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if (defined $pd and defined $dd and $di ne $pi and $dd == $pd) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $pd and defined $dd and $di ne $pi and $dd == $pd
defined $pd and defined $dd and $di ne $pi
defined $pd and defined $dd
MC/DC0%0/4
defined $pd and defined $dd and $di ne $pi and $dd == $pd
defined $pd
defined $dd
$di ne $pi
$dd == $pd
Truth table0%0/5
A and B and C and D
A= defined $pdB= defined $ddC= $di ne $piD= $dd == $pd
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $ENV{'PWD'}="$2$3"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $chdir_init = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | sub chdir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | my $newdir = @_ ? shift : ''; # allow for no arg (chdir to HOME dir) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chdir: not called CC=16 SCAR=56.1
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if ($^O eq "cygwin") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $newdir =~ s|\A///+|//|; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $newdir =~ s|(?<=[^/])//+|/|g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | elsif ($^O ne 'MSWin32') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $newdir =~ s|///*|/|g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | chdir_init() unless $chdir_init; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | my $newpwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | if ($^O eq 'MSWin32') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | # get the full path name *before* the chdir() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $newpwd = Win32::GetFullPathName($newdir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | return 0 unless CORE::chdir $newdir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | if ($^O eq 'VMS') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | return $ENV{'PWD'} = $ENV{'DEFAULT'} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | elsif ($^O eq 'MSWin32') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $ENV{'PWD'} = $newpwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if (ref $newdir eq 'GLOB') { # in case a file/dir handle is passed in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | $ENV{'PWD'} = cwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } elsif ($newdir =~ m#^/#s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $ENV{'PWD'} = $newdir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my @curdir = split(m#/#,$ENV{'PWD'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | @curdir = ('') unless @curdir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my $component; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | foreach $component (split(m#/#, $newdir)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | next if $component eq '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | pop(@curdir),next if $component eq '..'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | push(@curdir,$component); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | $ENV{'PWD'} = join('/',@curdir) || '/'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
join('/', @curdir) || '/'
MC/DC0%0/1
join('/', @curdir) || '/'
join('/', @curdir)
Truth table0%0/2
A
A= join('/', @curdir)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | sub _perl_abs_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | my $start = @_ ? shift : '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_perl_abs_path: not called CC=22 SCAR=62.3
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my($dotdots, $cwd, @pst, @cst, $dir, @tst); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | unless (@cst = stat( $start )) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | unless (-d _) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | # Make sure we can be invoked on plain files, not just directories. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | # NOTE that this routine assumes that '/' is the only directory separator. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | my ($dir, $file) = $start =~ m{^(.*)/(.+)$} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | or return cwd() . '/' . $start; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # Can't use "-l _" here, because the previous stat was a stat(), not an lstat(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | if (-l $start) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my $link_target = readlink($start); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | die "Can't resolve link $start: $!" unless defined $link_target; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | require File::Spec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | $link_target = $dir . '/' . $link_target | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | unless File::Spec->file_name_is_absolute($link_target); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | return abs_path($link_target); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | return $dir ? abs_path($dir) . "/$file" : "/$file"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | $cwd = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $dotdots = $start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $dotdots .= '/..'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | @pst = @cst; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | local *PARENT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | unless (opendir(PARENT, $dotdots)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | unless (@cst = stat($dotdots)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my $e = $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | closedir(PARENT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | $! = $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | if ($pst[0] == $cst[0] && $pst[1] eq $cst[1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pst[0] == $cst[0] and $pst[1] eq $cst[1]
MC/DC0%0/2
$pst[0] == $cst[0] and $pst[1] eq $cst[1]
$pst[0] == $cst[0]
$pst[1] eq $cst[1]
Truth table0%0/3
A and B
A= $pst[0] == $cst[0]B= $pst[1] eq $cst[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $dir = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$dir eq "." or $dir eq ".." or $tst[0] != $pst[0] or $tst[1] ne $pst[1]
$dir eq "." or $dir eq ".." or $tst[0] != $pst[0]
$dir eq "." or $dir eq ".."
MC/DC0%0/4
$dir eq "." or $dir eq ".." or $tst[0] != $pst[0] or $tst[1] ne $pst[1]
$dir eq "."
$dir eq ".."
$tst[0] != $pst[0]
$tst[1] ne $pst[1]
Truth table0%0/5
A or B or C or D
A= $dir eq "."B= $dir eq ".."C= $tst[0] != $pst[0]D= $tst[1] ne $pst[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | unless (defined ($dir = readdir(PARENT))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | closedir(PARENT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | require Errno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | $! = Errno::ENOENT(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | $tst[0] = $pst[0]+1 unless (@tst = lstat("$dotdots/$dir")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | while ($dir eq '.' || $dir eq '..' || $tst[0] != $pst[0] || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | $tst[1] ne $pst[1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | $cwd = (defined $dir ? "$dir" : "" ) . "/$cwd" ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | closedir(PARENT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } while (defined $dir); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | chop($cwd) unless $cwd eq '/'; # drop the trailing / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | $cwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | my $Curdir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | sub fast_abs_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | local $ENV{PWD} = $ENV{PWD} || ''; # Guard against clobberage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fast_abs_path: not called CC=15 SCAR=54.8
Pod
documented
Condition0%0/2
$ENV{'PWD'} || ''
MC/DC0%0/1
$ENV{'PWD'} || ''
$ENV{'PWD'}
Truth table0%0/2
A
A= $ENV{'PWD'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | my $cwd = getcwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | defined $cwd or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | require File::Spec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | my $path = @_ ? shift : ($Curdir ||= File::Spec->curdir); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Curdir ||= "File::Spec"->curdir
MC/DC0%0/2
$Curdir ||= "File::Spec"->curdir
$Curdir
"File::Spec"->curdir
Truth table0%0/3
A ||= B
A= $CurdirB= "File::Spec"->curdir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | # Detaint else we'll explode in taint mode. This is safe because | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | # we're not doing anything dangerous with it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ($path) = $path =~ /(.*)/s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ($cwd) = $cwd =~ /(.*)/s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | unless (-e $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | require Errno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $! = Errno::ENOENT(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | unless (-d _) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # Make sure we can be invoked on plain files, not just directories. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | my ($vol, $dir, $file) = File::Spec->splitpath($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | return File::Spec->catfile($cwd, $path) unless length $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | if (-l $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | my $link_target = readlink($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | defined $link_target or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | $link_target = File::Spec->catpath($vol, $dir, $link_target) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | unless File::Spec->file_name_is_absolute($link_target); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | return fast_abs_path($link_target); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | return $dir eq File::Spec->rootdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | ? File::Spec->catpath($vol, $dir, $file) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | : fast_abs_path(File::Spec->catpath($vol, $dir, '')) . '/' . $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | if (!CORE::chdir($path)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my $realpath = getcwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | if (! ((-d $cwd) && (CORE::chdir($cwd)))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d $cwd and CORE::chdir $cwd
MC/DC0%0/2
-d $cwd and CORE::chdir $cwd
-d $cwd
CORE::chdir $cwd
Truth table0%0/3
A and B
A= -d $cwdB= CORE::chdir $cwd
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | _croak("Cannot chdir back to $cwd: $!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $realpath; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | # added function alias to follow principle of least surprise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | # based on previous aliasing. --tchrist 27-Jan-00 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | *fast_realpath = \&fast_abs_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | # --- PORTING SECTION --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | # VMS: $ENV{'DEFAULT'} points to default directory at all times | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | # 06-Mar-1996 Charles Bailey bailey@newman.upenn.edu | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | # Note: Use of Cwd::chdir() causes the logical name PWD to be defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # in the process logical name table as the default device and directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | # seen by Perl. This may not be the same as the default device | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | # and directory seen by DCL after Perl exits, since the effects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | # the CRTL chdir() function persist only until Perl exits. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | sub _vms_cwd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | return $ENV{'DEFAULT'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vms_cwd: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | sub _vms_abs_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | return $ENV{'DEFAULT'} unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vms_abs_path: not called CC=15 SCAR=54.8
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | my $efs = _vms_efs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | my $unix_rpt = _vms_unix_rpt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | if (defined &VMS::Filespec::vmsrealpath) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | my $path_unix = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | my $path_vms = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | $path_unix = 1 if ($path =~ m#(?<=\^)/#); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | $path_unix = 1 if ($path =~ /^\.\.?$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | $path_vms = 1 if ($path =~ m#[\[<\]]#); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | $path_vms = 1 if ($path =~ /^--?$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | my $unix_mode = $path_unix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | if ($efs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | # In case of a tie, the Unix report mode decides. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | if ($path_vms == $path_unix) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $unix_mode = $unix_rpt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | $unix_mode = 0 if $path_vms; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | if ($unix_mode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | # Unix format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | return VMS::Filespec::unixrealpath($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | # VMS format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | my $new_path = VMS::Filespec::vmsrealpath($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | # Perl expects directories to be in directory format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | $new_path = VMS::Filespec::pathify($new_path) if -d $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | return $new_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # Fallback to older algorithm if correct ones are not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | # available. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | if (-l $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | my $link_target = readlink($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | die "Can't resolve link $path: $!" unless defined $link_target; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | return _vms_abs_path($link_target); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # may need to turn foo.dir into [.foo] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | my $pathified = VMS::Filespec::pathify($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | $path = $pathified if defined $pathified; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | return VMS::Filespec::rmsexpand($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | sub _os2_cwd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | my $pwd = `cmd /c cd`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_os2_cwd: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | chomp $pwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $pwd =~ s:\\:/:g ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | $ENV{'PWD'} = $pwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | return $pwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | sub _win32_cwd_simple { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | my $pwd = `cd`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_win32_cwd_simple: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | chomp $pwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $pwd =~ s:\\:/:g ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $ENV{'PWD'} = $pwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | return $pwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | sub _win32_cwd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | my $pwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_win32_cwd: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | $pwd = Win32::GetCwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $pwd =~ s:\\:/:g ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $ENV{'PWD'} = $pwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | return $pwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | *_NT_cwd = defined &Win32::GetCwd ? \&_win32_cwd : \&_win32_cwd_simple; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | sub _dos_cwd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | my $pwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dos_cwd: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | if (!defined &Dos::GetCwd) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | chomp($pwd = `command /c cd`); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | $pwd =~ s:\\:/:g ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $pwd = Dos::GetCwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | $ENV{'PWD'} = $pwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | return $pwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | sub _qnx_cwd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | local $ENV{PATH} = ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_qnx_cwd: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | local $ENV{CDPATH} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | local $ENV{ENV} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | my $pwd = `/usr/bin/fullpath -t`; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | chomp $pwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | $ENV{'PWD'} = $pwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | return $pwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | sub _qnx_abs_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | local $ENV{PATH} = ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_qnx_abs_path: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | local $ENV{CDPATH} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | local $ENV{ENV} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | ▶ | my $path = @_ ? shift : '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | local *REALPATH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | ▶ | defined( open(REALPATH, '-|') || exec '/usr/bin/fullpath', '-t', $path ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
open(REALPATH, '-|') || exec('/usr/bin/fullpath', '-t', $path)
MC/DC0%0/1
open(REALPATH, '-|') || exec('/usr/bin/fullpath', '-t', $path)
open(REALPATH, '-|')
Truth table0%0/2
A
A= open(REALPATH, '-|')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | die "Can't open /usr/bin/fullpath: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | my $realpath = <REALPATH>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | close REALPATH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | chomp $realpath; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | return $realpath; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | # Now that all the base-level functions are set up, alias the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | # user-level functions to the right places | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | if (exists $METHOD_MAP{$^O}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | my $map = $METHOD_MAP{$^O}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | foreach my $name (keys %$map) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | local $^W = 0; # assignments trigger 'subroutine redefined' warning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | *{$name} = \&{$map->{$name}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | # built-in from 5.30 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | *getcwd = \&Internals::getcwd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | if !defined &getcwd && defined &Internals::getcwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | # In case the XS version doesn't load. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | *abs_path = \&_perl_abs_path unless defined &abs_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | *getcwd = \&_perl_getcwd unless defined &getcwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | # added function alias for those of us more | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | # used to the libc function. --tchrist 27-Jan-00 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | *realpath = \&abs_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||