gozer 2003/11/16 17:11:06
Modified: . Changes
src/modules/perl modperl_cmd.c
t/conf extra.last.conf.in
t/response/TestDirective perldo.pm
Log:
<Perl> sections now proprely set $0 to the name of the configuration
file they are in. [Philippe M. Chiasson]
Reviewed by: stas
Revision Changes Path
1.253 +3 -0 modperl-2.0/Changes
Index: Changes
===================================================================
RCS file: /home/cvs/modperl-2.0/Changes,v
retrieving revision 1.252
retrieving revision 1.253
diff -u -r1.252 -r1.253
--- Changes 15 Nov 2003 21:15:45 -0000 1.252
+++ Changes 17 Nov 2003 01:11:06 -0000 1.253
@@ -12,6 +12,9 @@
=item 1.99_12-dev
+<Perl> sections now proprely set $0 to the name of the configuration
+file they are in. [Philippe M. Chiasson]
+
Apache::Status: provide a workaround for Config::myconfig() which
fails under threads with (5.8.0 < perl < 5.8.3) [Elizabeth Mattijsen
<[EMAIL PROTECTED]>]
1.51 +18 -0 modperl-2.0/src/modules/perl/modperl_cmd.c
Index: modperl_cmd.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_cmd.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- modperl_cmd.c 13 Nov 2003 21:03:46 -0000 1.50
+++ modperl_cmd.c 17 Nov 2003 01:11:06 -0000 1.51
@@ -365,6 +365,8 @@
const char *line_header = NULL;
int status = OK;
AV *args = Nullav;
+ SV *dollar_zero = Nullsv;
+ int dollar_zero_tainted;
#ifdef USE_ITHREADS
MP_dSCFG(s);
pTHX;
@@ -409,7 +411,23 @@
arg, NULL);
}
+ /* Set $0 to the current configuration file */
+ dollar_zero = get_sv("0", TRUE);
+ dollar_zero_tainted = SvTAINTED(dollar_zero);
+
+ if (dollar_zero_tainted) {
+ SvTAINTED_off(dollar_zero);
+ }
+
+ ENTER;
+ save_item(dollar_zero);
+ sv_setpv(dollar_zero, parms->directive->filename);
eval_pv(arg, FALSE);
+ LEAVE;
+
+ if (dollar_zero_tainted) {
+ SvTAINTED_on(dollar_zero);
+ }
if (SvTRUE(ERRSV)) {
SV *strict;
1.9 +1 -0 modperl-2.0/t/conf/extra.last.conf.in
Index: extra.last.conf.in
===================================================================
RCS file: /home/cvs/modperl-2.0/t/conf/extra.last.conf.in,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- extra.last.conf.in 13 Nov 2003 21:03:46 -0000 1.8
+++ extra.last.conf.in 17 Nov 2003 01:11:06 -0000 1.9
@@ -24,6 +24,7 @@
<Perl >
$Apache::Server::SaveConfig = 1;
$TestDirective::perl::filename = __FILE__;
+$TestDirective::perl::dollar_zero = $0;
$TestDirective::perl::line = __LINE__;
</Perl>
1.5 +4 -1 modperl-2.0/t/response/TestDirective/perldo.pm
Index: perldo.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestDirective/perldo.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- perldo.pm 13 Nov 2003 21:03:47 -0000 1.4
+++ perldo.pm 17 Nov 2003 01:11:06 -0000 1.5
@@ -10,7 +10,7 @@
sub handler {
my $r = shift;
- plan $r, tests => 7;
+ plan $r, tests => 9;
ok t_cmp('yes', $TestDirective::perl::worked);
@@ -22,10 +22,13 @@
ok t_cmp('yes', $TestDirective::perl::comments);
+ ok t_cmp(qr/extra.last.conf/, $TestDirective::perl::dollar_zero, '$0');
ok t_cmp(qr/extra.last.conf/, $TestDirective::perl::filename, '__FILE__');
# 3 would mean we are still counting lines from the context of the eval
ok $TestDirective::perl::line > 3;
+
+ ok t_cmp("-e", $0, '$0');
Apache::OK;
}