You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by st...@apache.org on 2005/03/18 17:48:53 UTC

svn commit: r158094 - in perl/modperl/trunk: Changes ModPerl-Registry/lib/ModPerl/PerlRun.pm ModPerl-Registry/lib/ModPerl/Registry.pm ModPerl-Registry/lib/ModPerl/RegistryCooker.pm

Author: stas
Date: Fri Mar 18 08:48:51 2005
New Revision: 158094

URL: http://svn.apache.org/viewcvs?view=rev&rev=158094
Log:
ModPerl::RegistryCooker API change: s/rewrite_shebang/shebang_to_perl/
the new API now returns the string to prepend before the rest of the
script, instead of rewriting the content, which is both faster and
doesn't mislead the perl debugger
Contributed by: Dominique Quatravaux <do...@idealx.com>

Modified:
    perl/modperl/trunk/Changes
    perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/PerlRun.pm
    perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/Registry.pm
    perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm

Modified: perl/modperl/trunk/Changes
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/Changes?view=diff&r1=158093&r2=158094
==============================================================================
--- perl/modperl/trunk/Changes (original)
+++ perl/modperl/trunk/Changes Fri Mar 18 08:48:51 2005
@@ -12,6 +12,12 @@
 
 =item 1.999_22-dev
 
+ModPerl::RegistryCooker API change: s/rewrite_shebang/shebang_to_perl/
+the new API now returns the string to prepend before the rest of the
+script, instead of rewriting the content, which is both faster and
+doesn't mislead the perl debugger [Dominique Quatravaux
+<do...@idealx.com>]
+
 add $ENV{MOD_PERL_API_VERSION} as something that clearly distinguishes
 which mod_perl version is being used at request time.  [Geoffrey Young]
 

Modified: perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/PerlRun.pm
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/PerlRun.pm?view=diff&r1=158093&r2=158094
==============================================================================
--- perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/PerlRun.pm (original)
+++ perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/PerlRun.pm Fri Mar 18 08:48:51 2005
@@ -50,7 +50,7 @@
     cache_table     => 'cache_table_common',
     cache_it        => 'NOP',
     read_script     => 'read_script',
-    rewrite_shebang => 'rewrite_shebang',
+    shebang_to_perl => 'shebang_to_perl',
     get_script_name => 'get_script_name',
     chdir_file      => 'chdir_file_normal',
     get_mark_line   => 'get_mark_line',

Modified: perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/Registry.pm
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/Registry.pm?view=diff&r1=158093&r2=158094
==============================================================================
--- perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/Registry.pm (original)
+++ perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/Registry.pm Fri Mar 18 08:48:51 2005
@@ -50,7 +50,7 @@
     cache_table     => 'cache_table_common',
     cache_it        => 'cache_it',
     read_script     => 'read_script',
-    rewrite_shebang => 'rewrite_shebang',
+    shebang_to_perl => 'shebang_to_perl',
     get_script_name => 'get_script_name',
     chdir_file      => 'chdir_file_normal',
     get_mark_line   => 'get_mark_line',

Modified: perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm?view=diff&r1=158093&r2=158094
==============================================================================
--- perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm (original)
+++ perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm Fri Mar 18 08:48:51 2005
@@ -371,7 +371,7 @@
     return $rc unless $rc == Apache::OK;
 
     # convert the shebang line opts into perl code
-    $self->rewrite_shebang;
+    my $shebang = $self->shebang_to_perl;
 
     # mod_cgi compat, should compile the code while in its dir, so
     # relative require/open will work.
@@ -397,6 +397,7 @@
                     "sub handler {",
                     "local \$0 = '$script_name';",
                     $nph,
+                    $shebang,
                     $line,
                     ${ $self->{CODE} },
                     "\n}"; # last line comment without newline?
@@ -553,13 +554,13 @@
 }
 
 #########################################################################
-# func: rewrite_shebang
-# dflt: rewrite_shebang
+# func: shebang_to_perl
+# dflt: shebang_to_perl
 # desc: parse the shebang line and convert command line switches
 #       (defined in %switches) into a perl code.
 # args: $self - registry blessed object
-# rtrn: nothing
-# efct: the CODE field gets adjusted
+# rtrn: a Perl snippet to be put at the beginning of the CODE field
+#       by caller
 #########################################################################
 
 my %switches = (
@@ -572,12 +573,12 @@
    'w' => sub { "use warnings;\n" },
 );
 
-sub rewrite_shebang {
+sub shebang_to_perl {
     my $self = shift;
     my($line) = ${ $self->{CODE} } =~ /^(.*)$/m;
     my @cmdline = split /\s+/, $line;
-    return unless @cmdline;
-    return unless shift(@cmdline) =~ /^\#!/;
+    return "" unless @cmdline;
+    return "" unless shift(@cmdline) =~ /^\#!/;
 
     my $prepend = "";
     for my $s (@cmdline) {
@@ -588,7 +589,8 @@
             $prepend .= $switches{$_}->();
         }
     }
-    ${ $self->{CODE} } =~ s/^/$prepend/ if $prepend;
+
+    return $prepend;
 }
 
 #########################################################################