Stas Bekman wrote:
Philippe M. Chiasson wrote:


        ok t_filepath_cmp(canonpath(Apache->server_root_relative),
                          canonpath($server_root),
                          'Apache->server_root_relative()');
+
+        ok t_filepath_cmp(canonpath(Apache->server_root_relative('/tmp')),
+                          canonpath('/tmp'),
+                          "Apache->server_root_relative('/tmp')");
    }


I think it's more like:

    $path = catdir Apache::ServerUtil::server_root, "logs";
    ok t_filepath_cmp(canonpath(Apache->server_root_relative($path)),
                          canonpath($path),
                          "Apache->server_root_relative($path)");

since usually it's:

$r->server_root_relative($component), where $component is either relative to serverroot or already a full path (whose base is serverroot)

Yes, see attached patch.

As it turns out File::Spec->file_name_is_absolute(undef) is apparently not
absolute, so testing for defined'ess is redundant, but I'd leave it in anways,
as it makes the goal of the code clearer.

--
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
Index: lib/Apache/compat.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v
retrieving revision 1.114
diff -u -I$Id -r1.114 compat.pm
--- lib/Apache/compat.pm	24 Jul 2004 07:27:03 -0000	1.114
+++ lib/Apache/compat.pm	9 Aug 2004 21:16:18 -0000
@@ -249,8 +249,13 @@
 package Apache;
 
 sub server_root_relative {
-    my $class = shift;
-    File::Spec->catfile(Apache::ServerUtil::server_root, @_);
+    my ($class, $path, @extra) = @_;
+    if (defined($path) && File::Spec->file_name_is_absolute($path)) {
+        return File::Spec->catfile($path, @extra); 
+    }
+    else {
+        File::Spec->catfile(Apache::ServerUtil::server_root, $path, @extra);
+    }
 }
 
 sub exit {
Index: t/response/TestCompat/apache.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestCompat/apache.pm,v
retrieving revision 1.16
diff -u -I$Id -r1.16 apache.pm
--- t/response/TestCompat/apache.pm	16 Jul 2004 01:10:46 -0000	1.16
+++ t/response/TestCompat/apache.pm	9 Aug 2004 21:16:18 -0000
@@ -17,7 +17,7 @@
 sub handler {
     my $r = shift;
 
-    plan $r, tests => 16;
+    plan $r, tests => 17;
 
     $r->send_http_header('text/plain');
 
@@ -86,6 +86,11 @@
         ok t_filepath_cmp(canonpath(Apache->server_root_relative),
                           canonpath($server_root),
                           'Apache->server_root_relative()');
+
+        my $path = catfile(Apache::ServerUtil::server_root, 'logs');
+        ok t_filepath_cmp(canonpath(Apache->server_root_relative($path)),
+                          canonpath($path),
+                          "Apache->server_root_relative('$path')");
     }
 
     OK;

Attachment: signature.asc
Description: OpenPGP digital signature



Reply via email to