Norton T. Allen [Wed, 27 Jun 2001 10:33:05 +0000 (06:33 -0400)]
Message-Id: <
200106271433.KAA04947@bottesini.harvard.edu>
p4raw-id: //depot/perl@10988
sub canonpath {
my($self,$path) = @_;
+
+ # Handle POSIX-style node names beginning with double slash
my $node = '';
- if ( $^O eq 'qnx' && $path =~ s|^(//\d+)/|/|s ) {
+ if ( $^O =~ m/^qnx|nto$/ && $path =~ s:^(//[^/]+)(/|\z):/:s ) {
$node = $1;
}
$path =~ s|(?<=[^/])/+|/|g ; # xx////xx -> xx/xx
$path =~ s|(/\.)+/|/|g ; # xx/././xx -> xx/xx
$path =~ s|^(\./)+||s unless $path eq "./"; # ./xx -> xx
$path =~ s|(?<=[^/])/\z|| ; # xx/ -> xx
- "$node$path";
+ return "$node$path";
}
=item catdir
sub canonpath {
my ($self,$path) = @_;
+
+ # Handle POSIX-style node names beginning with double slash
+ my $node = '';
+ if ( $^O =~ m/^qnx|nto$/ && $path =~ s:^(//[^/]+)(/|\z):/:s ) {
+ $node = $1;
+ }
$path =~ s|/+|/|g unless($^O eq 'cygwin'); # xx////xx -> xx/xx
$path =~ s|(/\.)+/|/|g; # xx/././xx -> xx/xx
$path =~ s|^(\./)+||s unless $path eq "./"; # ./xx -> xx
$path =~ s|^/(\.\./)+|/|s; # /../../xx -> xx
$path =~ s|/\Z(?!\n)|| unless $path eq "/"; # xx/ -> xx
- return $path;
+ return "$node$path";
}
=item catdir