Re: [BUG] line numbering off-by-one with Apache::DB and RegistryCooker

[prev] [thread] [next] [Date index for 2005/03/18]

From: Dominique Quatravaux
Subject: Re: [BUG] line numbering off-by-one with Apache::DB and RegistryCooker
Date: 14:10 on 18 Mar 2005
--2fHTh5uZTiUOsy+g
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I wrote:

>The other problem is that I cannot Do The Right Thing while keeping
>the current API intact. I propose the attached patch as an alternative,

Stop the press! My patch was incomplete: I forgot to rename
"rewrite_shebang()" into "shebang_to_perl()" in subclasses
ModPerl::Registry and ModPerl::PerlRun. Here is an updated patch.

Index: ModPerl-Registry/lib/ModPerl/PerlRun.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- ModPerl-Registry/lib/ModPerl/PerlRun.pm	(revision 158046)
+++ ModPerl-Registry/lib/ModPerl/PerlRun.pm	(working copy)
@@ -50,7 +50,7 @@
     cache_table     =3D> 'cache_table_common',
     cache_it        =3D> 'NOP',
     read_script     =3D> 'read_script',
-    rewrite_shebang =3D> 'rewrite_shebang',
+    shebang_to_perl =3D> 'shebang_to_perl',
     get_script_name =3D> 'get_script_name',
     chdir_file      =3D> 'chdir_file_normal',
     get_mark_line   =3D> 'get_mark_line',
Index: ModPerl-Registry/lib/ModPerl/Registry.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- ModPerl-Registry/lib/ModPerl/Registry.pm	(revision 158046)
+++ ModPerl-Registry/lib/ModPerl/Registry.pm	(working copy)
@@ -50,7 +50,7 @@
     cache_table     =3D> 'cache_table_common',
     cache_it        =3D> 'cache_it',
     read_script     =3D> 'read_script',
-    rewrite_shebang =3D> 'rewrite_shebang',
+    shebang_to_perl =3D> 'shebang_to_perl',
     get_script_name =3D> 'get_script_name',
     chdir_file      =3D> 'chdir_file_normal',
     get_mark_line   =3D> 'get_mark_line',
Index: ModPerl-Registry/lib/ModPerl/RegistryCooker.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- ModPerl-Registry/lib/ModPerl/RegistryCooker.pm	(revision 158046)
+++ ModPerl-Registry/lib/ModPerl/RegistryCooker.pm	(working copy)
@@ -371,7 +371,7 @@
     return $rc unless $rc =3D=3D Apache::OK;
=20
     # convert the shebang line opts into perl code
-    $self->rewrite_shebang;
+	my $shebang =3D $self->shebang_to_perl;
=20
     # 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 =3D '$script_name';",
                     $nph,
+                    $shebang,
                     $line,
                     ${ $self->{CODE} },
                     "\n}"; # last line comment without newline?
@@ -553,13 +554,13 @@
 }
=20
 #########################################################################
-# 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
 #########################################################################
=20
 my %switches =3D (
@@ -572,7 +573,7 @@
    'w' =3D> sub { "use warnings;\n" },
 );
=20
-sub rewrite_shebang {
+sub shebang_to_perl {
     my $self =3D shift;
     my($line) =3D ${ $self->{CODE} } =3D~ /^(.*)$/m;
     my @cmdline =3D split /\s+/, $line;
@@ -588,7 +589,8 @@
             $prepend .=3D $switches{$_}->();
         }
     }
-    ${ $self->{CODE} } =3D~ s/^/$prepend/ if $prepend;
+
+	return $prepend;
 }
=20
 #########################################################################


--=20
Dominique QUATRAVAUX                           Ing=E9nieur senior
01 44 42 00 08                                 IDEALX


--2fHTh5uZTiUOsy+g
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFCOuFKMJAKAU3mjcsRAqfeAKCmidqygVOnQAqzVdJl97XXmb/zNwCcCheh
rrFyoS3vr5bwPp34rO6GTK4=
=wTsu
-----END PGP SIGNATURE-----

--2fHTh5uZTiUOsy+g--

(message missing)

Re: [BUG] line numbering off-by-one with Apache::DB and RegistryCooker
Dominique Quatravaux 14:10 on 18 Mar 2005

Generated at 16:59 on 18 Mar 2005 by mariachi v0.52