On Thu, 17 Aug 2000, Marek Rouchal DAT CAD HW Tel 25849 wrote:

> On Wed, 16 Aug 2000, Tim Jenness wrote:
> 
> TJ>Pod::Find seems to be assuming a '/' somewhere - noticeable on VMS.
> 
> Hmmm, I didn't find the place, it probably comes from File::Find.

As it turned out it came from the combination of Pod::Find's use of
canonpath and File::Find.  Unfortunately canonpath returns things
on VMS in VMS native style. for example:

    DKA100:[PERL.LIB.POD]

but file find does everything on VMS by default in unix style:

    /dka100/perl/lib/pod/

the problem was with mixing things such that the call to canonpath
resulted in:

   dka100:[perl]/lib/pod

for example.

> TJ>> On Wed, 16 Aug 2000, Peter Prymmer wrote:
> TJ>> > 
> TJ>> > %pods = pod_find("$THISDIR/lib");
> 
> The fix suggested by Tim will be included in one of the next Pod::Parser
> distributions (perhaps 1.18).

OK.

> TJ>Thanks.  That is a start, however, I am having a difficult time
> TJ>getting Pod::Find to return anything in from test number 2 and
> TJ>one-liner tests like it.
> TJ>
> TJ> $ perl -e "use Pod::Find qw(pod_find); print 
>pod_find({'-verbose'=>2},('dkb100:[perl.lib]'))"
> TJ> Can't cd to (dkb100:[perl.lib]/) user : no such file or directory
> TJ>
> TJ>tests 2 and 4 are troublesome.  I can coax 3 into passing by
> TJ>adding VMS specific code (keep in mind that the handling of pod
> TJ>on VMS is done by a separate Makefile hence $Config{privlib} is
> TJ>not quite the place to look.
> 
> What is the general place to look in, then?
> 
> TJ>  I suspect that either File::Find
> TJ>or Pod::Find will need some tweaking, in addition to portability
> TJ>fixes like the one that you suggest for t/pod/find.t.
> 
> Oh well. I hoped that relying on File::Find (and File::Spec) will save me
> from dealing with platform compatibility issues.
> 
> First of all, please check whether File::Find works ok on VMS. If not,
> this has to be fixed in first place, IMHO.

Yes File::Find.pm works and has been passing its regression tests for
quite a while (at least before 5.002).

> I had a look at perldoc and its logic of searching for PODs. It is full of
> "if $Is_VMS;" :-(
> Obviously my assumption that Perl internally converts UNIX-style paths
> (i.e. delimited with /) into the correct ones on the current platform -
> was wrong.

It is almost correct though.

> Please let me know what File::File prints for the Perl installation's lib
> directory. I saw that there is a function VMS::Filespec::unixpath. If all
> I need to do is to run the output of cwd() and File::Find through this
> function on VMS, I'll happily include the code, but I'd prefer to get a
> patch from someone who can test these things directly on VMS.
> 
> Generally speaking, I'm against any OS-specific if clauses in high-level
> Perl modules, as long as things can be fixed in the low-level ones like
> File::Find, File::Spec and Cwd.

In the attached patch I simply omited the call to canonpath within
Pod::Find then I tossed a *lot* of VMS specific stuff into t/pod/find.t.
Some of this is due to the fact that perl's readdir() on VMS returns
all file names downcased, hence the lc() call.  Another bit is that
the VMS specific Makefile tosses a lot of the pod/*.pod into lib/pod/
as part of the `make all` target, hence on VMS the test's call to find
things returns a lot more than the simple list in the test.  I've filtered
that stuff out (in an admittedly ugly way - but the ugliness is limited to
VMS at least). Lastly the use of "***" for verbose test output on stdout
was incorrect, all the other tests that do that do so with a leading "#"
not a leading "*".

So here is the proposed fix:

diff -ru perl.6698/lib/Pod/Find.pm perl/lib/Pod/Find.pm
--- perl.6698/lib/Pod/Find.pm   Sun Aug 13 11:34:16 2000
+++ perl/lib/Pod/Find.pm        Fri Aug 18 17:23:13 2000
@@ -160,7 +160,9 @@
             $try = File::Spec->catfile($pwd,$try);
         }
         # simplify path
-        $try = File::Spec->canonpath($try);
+        # on VMS canonpath will vmsify:[the.path], but File::Find::find
+        # wants /unixy/paths
+        $try = File::Spec->canonpath($try) if ($^O ne 'VMS');
         my $name;
         if(-f $try) {
             if($name = _check_and_extract_name($try, $opts{-verbose})) {
diff -ru perl.6698/t/pod/find.t perl/t/pod/find.t
--- perl.6698/t/pod/find.t      Sun Aug 13 11:36:52 2000
+++ perl/t/pod/find.t   Fri Aug 18 17:37:31 2000
@@ -16,11 +16,16 @@
 require Cwd;
 my $THISDIR = Cwd::cwd();
 my $VERBOSE = 0;
-
-print "*** searching $THISDIR/lib\n";
-my %pods = pod_find("$THISDIR/lib");
+my $lib_dir = File::Spec->catdir($THISDIR,'lib');
+if ($^O eq 'VMS') {
+    $lib_dir = VMS::Filespec::unixify(File::Spec->catdir($THISDIR,'-','lib','pod'));
+    $Qlib_dir = $lib_dir;
+    $Qlib_dir =~ s#\/#::#g;
+}
+print "### searching $lib_dir\n";
+my %pods = pod_find("$lib_dir");
 my $result = join(',', sort values %pods);
-print "*** found $result\n";
+print "### found $result\n";
 my $compare = join(',', qw(
     Pod::Checker
     Pod::Find
@@ -31,28 +36,59 @@
     Pod::Select
     Pod::Usage
 ));
-ok($result,$compare);
+if ($^O eq 'VMS') {
+    $compare = lc($compare);
+    $result = join(',', sort grep {pod::} values %pods);
+    $result =~ s/$Qlib_dir/pod::/g;
+    my $count = 0;
+    my @result = split(/,/,$result);
+    my @compare = split(/,/,$compare);
+    foreach(@compare) {
+        $count += grep {/$_/} @result;
+    }
+    ok($count/($#result+1)-1,$#compare);
+}
+else {
+    ok($result,$compare);
+}
 
 # File::Find is located in this place since eons
 # and on all platforms, hopefully
 
-print "*** searching for File::Find\n";
+print "### searching for File::Find\n";
 $result = pod_where({ -inc => 1, -verbose => $VERBOSE }, 'File::Find')
   || 'undef - pod not found!';
-print "*** found $result\n";
+print "### found $result\n";
 
 require Config;
-$compare = File::Spec->catfile($Config::Config{privlib},"File","Find.pm");
-ok(_canon($result),_canon($compare));
+if ($^O eq 'VMS') { # privlib is perl_root:[lib] OK but not under mms
+    $compare = "lib.File]Find.pm";
+    $result =~ s/perl_root:\[\-?\.?//i;
+    $result =~ s/\[\-?\.?//i; # needed under `mms test`
+    ok($result,$compare);
+}
+else {
+    $compare = File::Spec->catfile($Config::Config{privlib},"File","Find.pm");
+    ok(_canon($result),_canon($compare));
+}
 
 # Search for a documentation pod rather than a module
-print "*** searching for perlfunc.pod\n";
+print "### searching for perlfunc.pod\n";
 $result = pod_where({ -inc => 1, -verbose => $VERBOSE }, 'perlfunc')
   || 'undef - perlfunc.pod not found!';
-print "*** found $result\n";
+print "### found $result\n";
 
-$compare =  File::Spec->catfile($Config::Config{privlib},"perlfunc.pod");
-ok(_canon($result),_canon($compare));
+if ($^O eq 'VMS') { # privlib is perl_root:[lib] unfortunately
+    $compare = "/lib/pod/perlfunc.pod";
+    $result = VMS::Filespec::unixify($result);
+    $result =~ s/perl_root\///i;
+    $result =~ s/^\.\.//;  # needed under `mms test`
+    ok($result,$compare);
+}
+else {
+    $compare = File::Spec->catfile($Config::Config{privlib},"perlfunc.pod");
+    ok(_canon($result),_canon($compare));
+}
 
 # make the path as generic as possible
 sub _canon
End of Patch.

Peter Prymmer



Reply via email to