# not be available.
BEGIN {
unless (eval { require re; })
- { eval ' sub re::import { $^H |= 0x00100000; } ' }
+ { eval ' sub re::import { $^H |= 0x00100000; } ' } # HINT_RE_TAINT
import re 'taint';
}
sub fileparse {
my($fullname,@suffices) = @_;
+ unless (defined $fullname) {
+ require Carp;
+ Carp::croak("fileparse(): need a valid pathname");
+ }
my($fstype,$igncase) = ($Fileparse_fstype, $Fileparse_igncase);
my($dirpath,$tail,$suffix,$basename);
my($taint) = substr($fullname,0,0); # Is $fullname tainted?
($dirpath,$basename) = ($fullname =~ /^((?:.*[:\\\/])?)(.*)/s);
$dirpath .= '.\\' unless $dirpath =~ /[\\\/]\z/;
}
+ elsif ($fstype =~ /^os2/i) {
+ ($dirpath,$basename) = ($fullname =~ m#^((?:.*[:\\/])?)(.*)#s);
+ $dirpath = './' unless $dirpath; # Can't be 0
+ $dirpath .= '/' unless $dirpath =~ m#[\\/]\z#;
+ }
elsif ($fstype =~ /^MacOS/si) {
($dirpath,$basename) = ($fullname =~ /^(.*:)?(.*)/s);
$dirpath = ':' unless $dirpath;
$tail .= $taint if defined $tail; # avoid warning if $tail == undef
wantarray ? ($basename .= $taint, $dirpath .= $taint, $tail)
- : $basename .= $taint;
+ : ($basename .= $taint);
}
}
$dirname .= ":" unless $dirname =~ /:\z/;
}
- elsif ($fstype =~ /MSDOS/i) {
- $dirname =~ s/([^:])[\\\/]*\z/$1/;
- unless( length($basename) ) {
- ($basename,$dirname) = fileparse $dirname;
- $dirname =~ s/([^:])[\\\/]*\z/$1/;
- }
- }
- elsif ($fstype =~ /MSWin32/i) {
+ elsif ($fstype =~ /MS(DOS|Win32)|os2/i) {
$dirname =~ s/([^:])[\\\/]*\z/$1/;
unless( length($basename) ) {
($basename,$dirname) = fileparse $dirname;