Integrate podlators-1.25
[p5sagit/p5-mst-13.2.git] / lib / File / CheckTree.pm
index b90945d..7884ca7 100644 (file)
@@ -1,8 +1,9 @@
 package File::CheckTree;
 
 use 5.006;
-use Exporter;
 use Cwd;
+use Exporter;
+use File::Spec;
 use warnings;
 use strict;
 
@@ -107,10 +108,11 @@ sub validate {
             my $this = $test;
 
             # expand relative $file to full pathname if preceded by cd directive
-            $file = $cwd . '/' . $file if $cwd && $file !~ m|^/|;
+            $file = File::Spec->catfile($cwd, $file) 
+                    if $cwd && !File::Spec->file_name_is_absolute($file);
 
             # put filename in after the test operator
-            $this =~ s/(-\w\b)/$1 "$file"/g;
+            $this =~ s/(-\w\b)/$1 "\$file"/g;
 
             # change the "-Z" representing a bundle with the $one test
             $this =~ s/-Z/-$one/;
@@ -130,7 +132,7 @@ sub validate {
                 # to call valmess instead of die/warn directly
                 # valmess will look up the error message from %Val_Message
                 $this =~ s/ ^ ( (\S+) \s+ \S+ ) \s* \|\| \s* (die|warn) \s* $
-                          /$1 || valmess('$3', '$2', '$file')/x;
+                          /$1 || valmess('$3', '$2', \$file)/x;
             }
 
             {
@@ -167,7 +169,7 @@ sub validate {
 
     # in case of any cd directives, return from whence we came
     if ($starting_dir ne cwd) {
-        chdir($starting_dir) || die "$starting_dir: $!";
+        chdir($starting_dir) || die "chdir $starting_dir: $!";
     }
 
     return $Warnings;