Change 11203 by pudge@pudge-mobile on 2001/07/07 23:43:06 Subject: [PATCHES] :t:pod: and :lib:Pod: stuff From: Thomas Wegner <[EMAIL PROTECTED]> Date: Thu, 5 Jul 2001 20:31:25 +0200 Message-Id: <p04320400b76a0fc8dea5@[149.225.100.38]> Affected files ... ... //depot/maint-5.6/macperl/lib/Pod/Find.pm#2 edit ... //depot/maint-5.6/macperl/t/pod/find.t#2 edit ... //depot/maint-5.6/macperl/t/pod/testp2pt.pl#2 edit Differences ... ==== //depot/maint-5.6/macperl/lib/Pod/Find.pm#2 (text) ==== Index: perl/lib/Pod/Find.pm --- perl/lib/Pod/Find.pm.~1~ Sat Jul 7 17:45:06 2001 +++ perl/lib/Pod/Find.pm Sat Jul 7 17:45:06 2001 @@ -128,12 +128,29 @@ if($opts{-script}) { require Config; - push(@search, $Config::Config{scriptdir}); + push(@search, $Config::Config{scriptdir}) + if -d $Config::Config{scriptdir}; $opts{-perl} = 1; } if($opts{-inc}) { - push(@search, grep($_ ne '.',@INC)); + if ($^O eq 'MacOS') { + # tolerate '.', './some_dir' and '(../)+some_dir' on Mac OS + my @new_INC = @INC; + for (@new_INC) { + if ( $_ eq '.' ) { + $_ = ':'; + } elsif ( $_ =~ s|^((?:\.\./)+)|':' x (length($1)/3)|e ) { + $_ = ':'. $_; + } else { + $_ =~ s|^\./|:|; + } + } + push(@search, grep($_ ne File::Spec->curdir, @new_INC)); + } else { + push(@search, grep($_ ne File::Spec->curdir, @INC)); + } + $opts{-perl} = 1; } @@ -144,9 +161,18 @@ # * remove e.g. "i586-linux" (from 'archname') # * remove e.g. 5.00503 # * remove pod/ if followed by *.pod (e.g. in pod/perlfunc.pod) - $SIMPLIFY_RX = - qq!^(?i:site(_perl)?/|\Q$Config::Config{archname}\E/|\\d+\\.\\d+([_.]?\\d+)?/|pod/(?=.*?\\.pod\\z))*!; + + # Mac OS: + # * remove ":?site_perl:" + # * remove :?pod: if followed by *.pod (e.g. in :pod:perlfunc.pod) + if ($^O eq 'MacOS') { + $SIMPLIFY_RX = + qq!^(?i:\:?site_perl\:|\:?pod\:(?=.*?\\.pod\\z))*!; + } else { + $SIMPLIFY_RX = + +qq!^(?i:site(_perl)?/|\Q$Config::Config{archname}\E/|\\d+\\.\\d+([_.]?\\d+)?/|pod/(?=.*?\\.pod\\z))*!; + } } my %dirs_visited; @@ -170,7 +196,7 @@ } next; } - my $root_rx = qq!^\Q$try\E/!; + my $root_rx = $^O eq 'MacOS' ? qq!^\Q$try\E! : qq!^\Q$try\E/!; File::Find::find( sub { my $item = $File::Find::name; if(-d) { @@ -231,10 +257,19 @@ $name =~ s!$SIMPLIFY_RX!!os if(defined $SIMPLIFY_RX); } else { - $name =~ s:^.*/::s; + if ($^O eq 'MacOS') { + $name =~ s/^.*://s; + } else { + $name =~ s:^.*/::s; + } } _simplify($name); $name =~ s!/+!::!g; #/ + if ($^O eq 'MacOS') { + $name =~ s!:+!::!g; # : -> :: + } else { + $name =~ s!/+!::!g; # / -> :: + } $name; } @@ -251,7 +286,11 @@ sub simplify_name { my ($str) = @_; # remove all path components - $str =~ s:^.*/::s; + if ($^O eq 'MacOS') { + $str =~ s/^.*://s; + } else { + $str =~ s:^.*/::s; + } _simplify($str); $str; } @@ -319,7 +358,7 @@ my %options = ( '-inc' => 0, '-verbose' => 0, - '-dirs' => [ '.' ], + '-dirs' => [ File::Spec->curdir ], ); # Check for an options hash as first argument @@ -347,6 +386,22 @@ require Config; # Add @INC + if ($^O eq 'MacOS' && $options{'-inc'}) { + # tolerate '.', './some_dir' and '(../)+some_dir' on Mac OS + my @new_INC = @INC; + for (@new_INC) { + if ( $_ eq '.' ) { + $_ = ':'; + } elsif ( $_ =~ s|^((?:\.\./)+)|':' x (length($1)/3)|e ) { + $_ = ':'. $_; + } else { + $_ =~ s|^\./|:|; + } + } + push (@search_dirs, @new_INC); + } elsif ($options{'-inc'}) { + push (@search_dirs, @INC); + } push (@search_dirs, @INC) if $options{'-inc'}; # Add location of pod documentation for perl man pages (eg perlfunc) @@ -364,7 +419,7 @@ # Loop over directories Dir: foreach my $dir ( @search_dirs ) { - # Don't bother if cant find the directory + # Don't bother if can't find the directory if (-d $dir) { warn "Looking in directory $dir\n" if $options{'-verbose'}; ==== //depot/maint-5.6/macperl/t/pod/find.t#2 (text) ==== Index: perl/t/pod/find.t --- perl/t/pod/find.t.~1~ Sat Jul 7 17:45:06 2001 +++ perl/t/pod/find.t Sat Jul 7 17:45:06 2001 @@ -21,7 +21,7 @@ require Cwd; my $THISDIR = Cwd::cwd(); my $VERBOSE = 0; -my $lib_dir = File::Spec->catdir($THISDIR,'..','lib','Pod'); +my $lib_dir = File::Spec->catdir($THISDIR,File::Spec->updir,'lib','Pod'); if ($^O eq 'VMS') { $lib_dir = VMS::Filespec::unixify(File::Spec->catdir($THISDIR,'-','lib','pod')); $Qlib_dir = $lib_dir; @@ -83,13 +83,15 @@ ok($result,$compare); } else { - $compare = File::Spec->catfile("..","lib","File","Find.pm"); + $compare = File::Spec->catfile(File::Spec->updir,"lib","File","Find.pm"); ok(_canon($result),_canon($compare)); } # Search for a documentation pod rather than a module print "### searching for perlfunc.pod\n"; -$result = pod_where({ -dirs => ['../pod'], -verbose => $VERBOSE }, 'perlfunc') +$result = pod_where({ + -dirs => [File::Spec->catdir(File::Spec->updir, "pod")], + -verbose => $VERBOSE }, 'perlfunc') || 'undef - perlfunc.pod not found!'; print "### found $result\n"; @@ -101,7 +103,7 @@ ok($result,$compare); } else { - $compare = File::Spec->catfile("..","pod","perlfunc.pod"); + $compare = File::Spec->catfile(File::Spec->updir,"pod","perlfunc.pod"); ok(_canon($result),_canon($compare)); } ==== //depot/maint-5.6/macperl/t/pod/testp2pt.pl#2 (text) ==== Index: perl/t/pod/testp2pt.pl --- perl/t/pod/testp2pt.pl.~1~ Sat Jul 7 17:45:06 2001 +++ perl/t/pod/testp2pt.pl Sat Jul 7 17:45:06 2001 @@ -47,8 +47,10 @@ $INSTDIR =~ s#/$##; $INSTDIR =~ s#/000000/#/#; } -$INSTDIR = (dirname $INSTDIR) if (basename($INSTDIR) eq 'pod'); -$INSTDIR = (dirname $INSTDIR) if (basename($INSTDIR) eq 't'); + +my $rm_dir = File::Spec->catdir('t', 'pod'); +$INSTDIR =~ s/$rm_dir$//; # cut 't/pod' from path (cut 't:pod:' on Mac OS) + my @PODINCDIRS = ( catfile($INSTDIR, 'lib', 'Pod'), catfile($INSTDIR, 'scripts'), catfile($INSTDIR, 'pod'), End of Patch.