The only objective benefit to using C<DirHandle> is that it avoids
namespace pollution by creating globs to hold directory handles.
+=head1 NOTES
+
+=over 4
+
+=item *
+
+On Mac OS (Classic), the path separator is ':', not '/', and the
+current directory is denoted as ':', not '.'. You should be careful
+about specifying relative pathnames. While a full path always begins
+with a volume name, a relative pathname should always begin with a
+':'. If specifying a volume name only, a trailing ':' is required.
+
+=back
+
=cut
require 5.000;
$dir eq 'Doc_Root:[Help]'
$type eq '.Rnh'
-=over 4
+=over
=item C<basename>
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(fileparse fileparse_set_fstype basename dirname);
-$VERSION = "2.6";
+$VERSION = "2.7";
# fileparse_set_fstype() - specify OS-based rules used in future
}
elsif ($fstype =~ /^MacOS/si) {
($dirpath,$basename) = ($fullname =~ /^(.*:)?(.*)/s);
+ $dirpath = ':' unless $dirpath;
}
elsif ($fstype =~ /^AmigaOS/i) {
($dirpath,$basename) = ($fullname =~ /(.*[:\/])?(.*)/s);
=cut
use strict;
-use 5.005_64;
+use 5.6.0;
use Carp;
our $VERSION = 1.0;
unshift @trypod, "./pod/perldiag.pod" if -e "pod/perldiag.pod";
(my $PODFILE) = ((grep { -e } @trypod), $trypod[$#trypod])[0];
+if ($^O eq 'MacOS') {
+ # just updir one from each lib dir, we'll find it ...
+ ($PODFILE) = grep { -e } map { "$_:pod:perldiag.pod" } @INC;
+}
+
+
$DEBUG ||= 0;
my $WHOAMI = ref bless []; # nobody's business, prolly not even mine
while ((s = moreswitches(s)))
;
}
+#ifdef MACOS_TRADITIONAL
+ break;
+#endif
}
}
}
# check "" interpretation
$x = "\n";
-# 10 is ASCII/Iso Latin, 21 is EBCDIC.
+# 10 is ASCII/Iso Latin, 13 in Mac OS, 21 is EBCDIC.
if ($x eq chr(10)) { print "ok 1\n";}
+elsif ($x eq chr(13)) { print "ok 1 # Mac OS\n"; }
elsif ($x eq chr(21)) { print "ok 1 # EBCDIC\n"; }
else {print "not ok 1\n";}
# check <> pseudoliteral
-open(try, "/dev/null") || open(try,"nla0:") || (die "Can't open /dev/null.");
+open(try, "/dev/null") || open(try,"Dev:Null") || open(try,"nla0:") || (die "Can't open /dev/null.");
if (<try> eq '') {
print "ok 6\n";
}
}
use Config;
-if ( $^O eq 'MSWin32' or
+if ( $^O eq 'MSWin32' or $^O eq 'MacOS' or
($Config{'cppstdin'} =~ /\bcppstdin\b/) and
( ! -x $Config{'binexp'} . "/cppstdin") ) {
print "1..0 # Skip: \$Config{cppstdin} unavailable\n";
if ($count == 7) {print "ok 3\n";} else {print "not ok 3\n";}
-$_ = ($^O eq 'MSWin32') ? `type Comp.try` : `cat Comp.try`;
+$_ = ($^O eq 'MSWin32') ? `type Comp.try`
+ : ($^O eq 'MacOS') ? `catenate Comp.try`
+ : `cat Comp.try`;
if (/.*\n.*\n.*\n$/) {print "ok 4\n";} else {print "not ok 4\n";}
print "1..3\n";
-$PERL = ($^O eq 'MSWin32') ? '.\perl' : './perl';
+$PERL = ($^O eq 'MSWin32') ? '.\perl'
+ : ($^O eq 'MacOS') ? $^X : './perl';
$x = `$PERL -le "print 'ok';"`;
if ($x eq "ok\n") {print "ok 1\n";} else {print "not ok 1\n";}
if (! -e $Dfile) {
($Dfile) = <Op_dbmx*>;
}
-if ($Is_Dosish) {
+if ($Is_Dosish || $^O eq 'MacOS') {
print "ok 2 # Skipped: different file permission semantics\n";
}
else {
BEGIN {
chdir 't' if -d 't';
- $dir = "auto-$$";
+ if ($^O eq 'MacOS') {
+ $dir = ":auto-$$";
+ $sep = ":";
+ } else {
+ $dir = "auto-$$";
+ $sep = "/";
+ }
@INC = $dir;
push @INC, '../lib';
}
# First we must set up some autoloader files
mkdir $dir, 0755 or die "Can't mkdir $dir: $!";
-mkdir "$dir/auto", 0755 or die "Can't mkdir: $!";
-mkdir "$dir/auto/Foo", 0755 or die "Can't mkdir: $!";
+mkdir "$dir${sep}auto", 0755 or die "Can't mkdir: $!";
+mkdir "$dir${sep}auto${sep}Foo", 0755 or die "Can't mkdir: $!";
-open(FOO, ">$dir/auto/Foo/foo.al") or die;
+open(FOO, ">$dir${sep}auto${sep}Foo${sep}foo.al") or die;
print FOO <<'EOT';
package Foo;
sub foo { shift; shift || "foo" }
EOT
close(FOO);
-open(BAR, ">$dir/auto/Foo/bar.al") or die;
+open(BAR, ">$dir${sep}auto${sep}Foo${sep}bar.al") or die;
print BAR <<'EOT';
package Foo;
sub bar { shift; shift || "bar" }
EOT
close(BAR);
-open(BAZ, ">$dir/auto/Foo/bazmarkhian.al") or die;
+open(BAZ, ">$dir${sep}auto${sep}Foo${sep}bazmarkhian.al") or die;
print BAZ <<'EOT';
package Foo;
sub bazmarkhianish { shift; shift || "baz" }
print "ok 9\n";
# test recursive autoloads
-open(F, ">$dir/auto/Foo/a.al") or die;
+open(F, ">$dir${sep}auto${sep}Foo${sep}a.al") or die;
print F <<'EOT';
package Foo;
BEGIN { b() }
EOT
close(F);
-open(F, ">$dir/auto/Foo/b.al") or die;
+open(F, ">$dir${sep}auto${sep}Foo${sep}b.al") or die;
print F <<'EOT';
package Foo;
sub b { print "ok 10\n"; }
# cleanup
END {
return unless $dir && -d $dir;
-unlink "$dir/auto/Foo/foo.al";
-unlink "$dir/auto/Foo/bar.al";
-unlink "$dir/auto/Foo/bazmarkhian.al";
-unlink "$dir/auto/Foo/a.al";
-unlink "$dir/auto/Foo/b.al";
-rmdir "$dir/auto/Foo";
-rmdir "$dir/auto";
+unlink "$dir${sep}auto${sep}Foo${sep}foo.al";
+unlink "$dir${sep}auto${sep}Foo${sep}bar.al";
+unlink "$dir${sep}auto${sep}Foo${sep}bazmarkhian.al";
+unlink "$dir${sep}auto${sep}Foo${sep}a.al";
+unlink "$dir${sep}auto${sep}Foo${sep}b.al";
+rmdir "$dir${sep}auto${sep}Foo";
+rmdir "$dir${sep}auto";
rmdir "$dir";
}
print "1..5\n";
-$dot = new DirHandle ".";
+$dot = new DirHandle ($^O eq 'MacOS' ? ':' : '.');
+
print defined($dot) ? "ok" : "not ok", " 1\n";
@a = sort <*>;
BEGIN {
chdir 't' if -d 't';
$dir = "self-$$";
+ $sep = "/";
+
+ if ($^O eq 'MacOS') {
+ $dir = ":" . $dir;
+ $sep = ":";
+ }
+
@INC = $dir;
push @INC, '../lib';
# First we must set up some selfloader files
mkdir $dir, 0755 or die "Can't mkdir $dir: $!";
- open(FOO, ">$dir/Foo.pm") or die;
+ open(FOO, ">$dir${sep}Foo.pm") or die;
print FOO <<'EOT';
package Foo;
use SelfLoader;
close(FOO);
- open(BAR, ">$dir/Bar.pm") or die;
+ open(BAR, ">$dir${sep}Bar.pm") or die;
print BAR <<'EOT';
package Bar;
use SelfLoader;
# cleanup
END {
return unless $dir && -d $dir;
-unlink "$dir/Foo.pm", "$dir/Bar.pm";
+unlink "$dir${sep}Foo.pm", "$dir${sep}Bar.pm";
rmdir "$dir";
}
@INC = '../lib';
$Is_VMS = $^O eq 'VMS';
$Is_MSWin32 = $^O eq 'MSWin32';
+$Is_MacOS = $^O eq 'MacOS';
$ENV{PERL5LIB} = "../lib" unless $Is_VMS;
$|=1;
print TEST "$prog\n";
close TEST;
my $results = $Is_VMS ?
- `MCR $^X "-I[-.lib]" $switch $tmpfile 2>&1` :
- $Is_MSWin32 ?
- `.\\perl -I../lib $switch $tmpfile 2>&1` :
- `./perl $switch $tmpfile 2>&1`;
+ `MCR $^X "-I[-.lib]" $switch $tmpfile 2>&1` :
+ $Is_MSWin32 ?
+ `.\\perl -I../lib $switch $tmpfile 2>&1` :
+ $Is_MacOS ?
+ `$^X -I::lib $switch $tmpfile` :
+ `./perl $switch $tmpfile 2>&1`;
my $status = $?;
$results =~ s/\n+$//;
# allow expected output to be written as if $prog is on STDIN
open CMD, ">$cmdfile"; print CMD $code; close CMD;
my $cmd = (($^O eq 'VMS') ? "MCR $^X"
: ($^O eq 'MSWin32') ? '.\perl'
+ : ($^O eq 'MacOS') ? $^X
: './perl');
$cmd .= " -w $cmdfile 2>$errfile";
if ($^O eq 'VMS' or $^O eq 'MSWin32') {
}
$wanted_filename = $^O eq 'VMS' ? '0.' : '0';
+$saved_filename = $^O eq 'MacOS' ? ':0' : './0';
print "not " if $warns;
print "ok 1\n";
-open(FILE,">./0");
+open(FILE,">$saved_filename");
print FILE "1\n";
print FILE "0";
close(FILE);
-open(FILE,"<./0");
+open(FILE,"<$saved_filename");
my $seen = 0;
my $dummy;
while (my $name = <FILE>)
print "ok 5\n";
close FILE;
-opendir(DIR,'.');
+opendir(DIR,($^O eq 'MacOS' ? ':' : '.'));
$seen = 0;
while (my $name = readdir(DIR))
{
print "not " unless $seen;
print "ok 11\n";
-unlink("./0");
+unlink($saved_filename);
my %hash = (0 => 1, 1 => 2);
exit(0);
}
+if ($^O eq 'MacOS') {
+ # XXX the system tests could be written to use ./perl and so work on Win32
+ print "1..0 # Mostly useless tests for Mac OS\n";
+ exit(0);
+}
+
print "1..8\n";
if ($^O ne 'os2') {
print "#2\t:$foo: == 4\n";
if ($foo == 4) {print "ok 2\n";} else {print "not ok 2\n";}
-$PERL = ($^O eq 'MSWin32') ? '.\perl' : './perl';
+$PERL = ($^O eq 'MSWin32') ? '.\perl' : ($^O eq 'MacOS') ? $^X : './perl';
$CMD = qq[$PERL -e "goto foo;" 2>&1 ];
$x = `$CMD`;
print +($x = unpack("%32B*", "Now is the time for all good blurfl")) == $sum
? "ok 7\n" : "not ok 7 $x\n";
-open(BIN, "./perl") || open(BIN, "./perl.exe")
+open(BIN, "./perl") || open(BIN, "./perl.exe") || open(BIN, $^X)
|| die "Can't open ../perl or ../perl.exe: $!\n";
sysread BIN, $foo, 8192;
close BIN;
$iters = shift || 1; # Poor man performance suite, 10000 is OK.
-open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests') ||
+open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests') || open(TESTS,':op:re_tests') ||
die "Can't open re_tests";
while (<TESTS>) { }
#!./perl
$skip_amp = 1;
-for $file ('op/regexp.t', 't/op/regexp.t') {
+for $file ('./op/regexp.t', './t/op/regexp.t', ':op:regexp.t') {
if (-r $file) {
- do "./$file";
+ do $file;
exit;
}
}
-die "Cannot find op/regexp.t or t/op/regexp.t\n";
+die "Cannot find ./op/regexp.t or ./t/op/regexp.t\n";
# Does assignment to a list imply split to one more field than that?
if ($^O eq 'MSWin32') { $foo = `.\\perl -D1024 -e "(\$a,\$b) = split;" 2>&1` }
elsif ($^O eq 'VMS') { $foo = `./perl "-D1024" -e "(\$a,\$b) = split;" 2>&1` }
+elsif ($^O eq 'MacOS'){ $foo = `$^X "-D1024" -e "(\$a,\$b) = split;"` }
else { $foo = `./perl -D1024 -e '(\$a,\$b) = split;' 2>&1` }
print $foo =~ /DEBUGGING/ || $foo =~ /SV = (VOID|IV\(3\))/ ? "ok 11\n" : "not ok 11\n";
print "1..44\n";
-my $CAT = ($^O eq 'MSWin32') ? 'type' : 'cat';
+my $CAT = ($^O eq 'MSWin32') ? 'type'
+ : ($^O eq 'MacOS') ? 'catenate' : 'cat';
format OUT =
the quick brown @<<
my @prgs = () ;
-foreach (sort glob("pragma/strict-*")) {
+foreach (sort glob($^O eq 'MacOS' ? ":pragma:strict-*" : "pragma/strict-*")) {
next if /(~|\.orig|,v)$/;
while (@files > 2) {
my $filename = shift @files ;
my $code = shift @files ;
+ $code =~ s|\./abc|:abc|g if $^O eq 'MacOS';
push @temps, $filename ;
open F, ">$filename" or die "Cannot open $filename: $!\n" ;
print F $code ;
}
shift @files ;
$prog = shift @files ;
+ $prog =~ s|\./abc|:abc|g if $^O eq 'MacOS';
}
open TEST, ">$tmpfile";
print TEST $prog,"\n";
close TEST;
my $results = $Is_MSWin32 ?
`.\\perl -I../lib $switch $tmpfile 2>&1` :
+ $^O eq 'MacOS' ?
+ `$^X -I::lib $switch $tmpfile` :
`./perl $switch $tmpfile 2>&1`;
my $status = $?;
$results =~ s/\n+$//;
$results =~ s/tmp\d+/-/g;
$results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg
$expected =~ s/\n+$//;
+ $expected =~ s|(\./)?abc\.pm|:abc.pm|g if $^O eq 'MacOS';
+ $expected =~ s|./abc|:abc|g if $^O eq 'MacOS';
my $prefix = ($results =~ s/^PREFIX\n//) ;
if ( $results =~ s/^SKIPPED\n//) {
print "$results\n" ;