Re: [BUG] line numbering off-by-one with Apache::DB and RegistryCooker
[prev]
[thread]
[next]
[Date index for 2005/03/15]
--6c2NcOVqGQ03X4Wi
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
> In which case you will end up with use warnings on the same line as the=
=20
> shebang line, no? which will look strange in the debugger
Actually I find this pretty idiomatic, look:
use warnings; #!/usr/bin/perl -w
No? :-) Besides this line is seldom debugged anyway (at least in my
experience) because the programmer typically sets a breakpoint with
"$DB::single=3D1;" directly in his/her CGI.
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,
but it rips the ModPerl::RegistryCooker->rewrite_shebang() method
apart (hopefully nobody depends on it yet, as it is undocumented).
> I wonder if it'd be cleaner to use the '#line number filename'
> directive.=20
Actually this is what is currently done, but *before*
->rewrite_shebang() fiddles with the first line, which results in an
off-by-one.
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 157426)
+++ 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
--6c2NcOVqGQ03X4Wi
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
iD8DBQFCNvdqMJAKAU3mjcsRAssPAJ98zIz88tnShjmFj0Z1VnmEksiAlwCfYMez
MuM5EcLfFrlt7nytDPYj3GU=
=mYGc
-----END PGP SIGNATURE-----
--6c2NcOVqGQ03X4Wi--
 |
(message missing)
|