On Sun, 30 Nov 2003, Stas Bekman wrote:

> Randy Kobes wrote:
>
> >>>Ah, what do you get as a response? a path like
> >>>/tmp/foo.pl on win32? In which case the problem would be
> >>>coming from:
> >>>
> >>>     $_[0]->{FILENAME} = $_[1]->filename;
> >>>
> >>>in RegistryCooker.pm, which sets $0, eventually printed
> >>>by cgi-bin/basic.pl. Does $r->filename return a unix
> >>>path on winFU?
>
> So does it do that? I suppose that it does...

Sorry, I forgot - yes, $r->filename does return a unix path
on Win32.

> >>I guess one could look at it from both ends ... I was
> >>thinking here that the problem was in the way that
> >>$script_file was constructed with catfile, which on
> >>Win32 came out as SERVER_ROOT\cgi-bin\basic.pl. So the
> >>patch above changes this to SERVER_ROOT/cgi-bin/basic.pl,
> >>which agrees with the response.
>
> Yes, but $script_file is a fs path, not URL. I'm not
> questioning the correctness of your patch, Randy, it just
> looks like you are workaround a problem that's coming from
> $r->filename. Is it possible that it may return the \
> paths as well?

I couldn't see within Apache a function that would return a
Win32 path in this context, and from some of the places that
use r->filename and the like, it appears that a Unix-like
path is assumed. Might this be for convenience, in that a
filename can be used to construct a URL, and they didn't
want to get into a lot of conversions when doing so?

> > Further to this, I think most people on Win32 (and probably
> > all non-Unices) are used to using '/' as a directory
> > separator when inside a web environment (eg, in constructing
> > urls). So I would think that SERVER_ROOT/cgi-bin/basic.pl
> > is the correct cross-platform value ...
> >
> > However (I hate bringing this up :(, on Win32 there's
> > problems with sometimes the dos short path name being
> > used and then compared with the long path name
> > (eg, MODPER~1.0 vs modperl-2.0). This in principle
> > is what needs to be done to get t/basic.t and t/redirect.t
> > to pass under ModPerl-Registry:
> [...]
> > -my $script_file = catfile $vars->{serverroot}, 'cgi-bin', 'basic.pl';
> > +my $script_file = File::Spec::Unix->catfile($vars->{serverroot}, 'cgi-bin', 
> > 'basic.pl');
>
> This looks absolutely unintuitive and requires a comment in every place you
> use it. Therefore you are probably better off with your original patch to do
> an explicit: join "/n", ...
>
> > +$script_file = Win32::GetLongPathName($script_file)
> > +    if Apache::TestConfig::WIN32;
>
> Yes, it's ugly and those of us coding on unix will never
> remember to do that, leaving you with the boring cleanup
> job. Therefore please think of extending Apache::TestXXX
> API to have this Win32::GetLongPathName part hidden
> within.  Both join "/", .. and Win32::GetLongPathName can
> go inside. e.g.  catfile_normalized() and
> caturl_normalized()? where any post-processings like
> Win32::GetLongPathName will come from the _normalized
> part? I'm not sure if the name selection is good. Does it
> sound good?

Yes, that sounds much better - I just included the diff
as an indication of what needed to be done. How about
the following:
=========================================================
Index: Apache-Test/lib/Apache/TestUtil.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestUtil.pm,v
retrieving revision 1.31
diff -u -r1.31 TestUtil.pm
--- Apache-Test/lib/Apache/TestUtil.pm  29 Apr 2003 08:04:04 -0000      1.31
+++ Apache-Test/lib/Apache/TestUtil.pm  1 Dec 2003 07:03:50 -0000
@@ -26,7 +26,8 @@
     t_client_log_error_is_expected t_client_log_warn_is_expected
 );

[EMAIL PROTECTED] = qw(t_write_perl_script t_write_shell_script t_chown);
[EMAIL PROTECTED] = qw(t_write_perl_script t_write_shell_script t_chown
+               catfile_normalized caturl_normalized);

 %CLEAN = ();

@@ -302,6 +303,18 @@
         t_debug("removing dir tree: $_");
         t_rmtree($_);
     }
+}
+
+sub catfile_normalized {
+    my $f = catfile(@_);
+    return Apache::TestConfig::WIN32 ?
+        Win32::GetLongPathName($f) : $f;
+}
+
+sub caturl_normalized {
+    my $f = File::Spec::Unix->catfile(@_);
+    return Apache::TestConfig::WIN32 ?
+        Win32::GetLongPathName($f) : $f;
 }

 1;
Index: ModPerl-Registry/t/basic.t
===================================================================
RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/t/basic.t,v
retrieving revision 1.15
diff -u -r1.15 basic.t
--- ModPerl-Registry/t/basic.t  23 Nov 2003 21:01:50 -0000      1.15
+++ ModPerl-Registry/t/basic.t  1 Dec 2003 07:03:50 -0000
@@ -6,7 +6,7 @@
 use Apache::TestRequest qw(GET GET_BODY HEAD);
 use Apache::TestConfig ();

-use File::Spec::Functions qw(catfile);
+use Apache::TestUtil qw(caturl_normalized);

 my %modules = (
     registry    => 'ModPerl::Registry',
@@ -19,7 +19,7 @@
 plan tests => @aliases * 4 + 3;

 my $vars = Apache::Test::config()->{vars};
-my $script_file = catfile $vars->{serverroot}, 'cgi-bin', 'basic.pl';
+my $script_file = caturl_normalized($vars->{serverroot}, 'cgi-bin', 'basic.pl');

 # very basic compilation/response test
 for my $alias (@aliases) {
Index: ModPerl-Registry/t/redirect.t
===================================================================
RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/t/redirect.t,v
retrieving revision 1.6
diff -u -r1.6 redirect.t
--- ModPerl-Registry/t/redirect.t       23 Nov 2003 21:01:50 -0000      1.6
+++ ModPerl-Registry/t/redirect.t       1 Dec 2003 07:03:50 -0000
@@ -5,7 +5,7 @@
 use Apache::TestUtil;
 use Apache::TestRequest qw(GET_BODY HEAD);

-use File::Spec::Functions qw(catfile);
+use Apache::TestUtil qw(caturl_normalized);

 plan tests => 4, have_lwp;

@@ -16,7 +16,7 @@
     my $redirect_path = "/registry/basic.pl";
     my $url = "$base_url?$redirect_path";
     my $vars = Apache::Test::config()->{vars};
-    my $script_file = catfile $vars->{serverroot}, 'cgi-bin', 'basic.pl';
+    my $script_file = caturl_normalized($vars->{serverroot}, 'cgi-bin', 'basic.pl');

     ok t_cmp(
         "ok $script_file",
=================================================================
If OK, I'll add some comments, and a short pod description
in Apache::TestUtil, of what caturl_normalized and
catfile_normalized are doing.

-- 
best regards,
randy

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to