Andreas J. Koenig wrote:
>>>>>> On Mon, 10 Jul 2006 12:20:30 -0700, "Philippe M. Chiasson" <[EMAIL 
>>>>>> PROTECTED]> said:
> 
>  >> ok, thanks for trying :)
>  >> 
>  >> I'm including gozer here, since he is the main PerlConfig guy - I
>  >> wouldn't want to step on his toes trying to implement a fix for this
>  >> issue.  but it we harp on him he will probably have an answer in a
>  >> matter of seconds ;)
> 
>   > Slightly longer than a few seconds, but here is a patch that will probably
>   > fix this issue as well as the the one linked to.
> 
> Very nice, thanks very, very much, it seems to work perfectly well.

Checked in as http://svn.apache.org/viewvc?view=rev&revision=422774

> One nit while we are at it: errors during execution of $PerlConfig
> would be much less pain if we could get real line numbers and file
> names. From the manpage I would believe that this is feasible now?

Yes, that's been annoying me for a long time as well...

> Look what I got (the error was well spotted and correct, but I still
> did not know where to search because I have many <Perl> sections and
> many $PerlConfig variables):
> 
> [Mon Jul 17 12:52:15 2006] [warn] The Alias directive in mod_perl at line 1 
> will probably never match because it overlaps an earlier Alias.

The attached patch should address this problem. Let me know if it works and
helps locating the source of that warning.

--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
Index: src/modules/perl/modperl_common_util.h
===================================================================
--- src/modules/perl/modperl_common_util.h	(revision 422775)
+++ src/modules/perl/modperl_common_util.h	(working copy)
@@ -77,6 +77,8 @@
 #define MP_magical_tie(sv, mg_flags) \
     SvFLAGS((SV*)sv) |= mg_flags
 
+#define MP_PERLSECTIONS_DIRECTIVE_SV \
+    get_sv("Apache2::PerlSections::Directive", TRUE)
 
 /* tie %hash */
 MP_INLINE SV *modperl_hash_tie(pTHX_ const char *classname,
Index: src/modules/perl/modperl_config.c
===================================================================
--- src/modules/perl/modperl_config.c	(revision 422775)
+++ src/modules/perl/modperl_config.c	(working copy)
@@ -480,6 +480,7 @@
 typedef struct {
     AV *av;
     I32 ix;
+    I32 skip;
     PerlInterpreter *perl;
 } svav_param_t;
 
@@ -495,10 +496,17 @@
         return NULL;
     }
 
-    sv = AvARRAY(av)[svav_param->ix++];
-    SvPV_force(sv, n_a);
-
-    apr_cpystrn(buf, SvPVX(sv), bufsiz);
+    /* Skipping lines is the only way to control the apparent
+     * line number when errors/warnings are reported
+     */
+    if (svav_param->skip-- > 0) {
+        apr_cpystrn(buf, "", bufsiz);
+    }
+    else {
+        sv = AvARRAY(av)[svav_param->ix++];
+        SvPV_force(sv, n_a);
+        apr_cpystrn(buf, SvPVX(sv), bufsiz);
+    }
 
     return buf;
 }
@@ -516,6 +524,8 @@
     cmd_parms parms;
     svav_param_t svav_parms;
     ap_directive_t *conftree = NULL;
+    SV *dsv = Nullsv;
+    const char *filename = "mod_perl";
 
     memset(&parms, '\0', sizeof(parms));
 
@@ -546,11 +556,22 @@
 
     svav_parms.av = (AV*)SvRV(lines);
     svav_parms.ix = 0;
+    svav_parms.skip = 0;
 #ifdef USE_ITHREADS
     svav_parms.perl = aTHX;
 #endif
 
-    parms.config_file = ap_pcfg_open_custom(p, "mod_perl",
+    dsv = MP_PERLSECTIONS_DIRECTIVE_SV;
+    if (SvROK(dsv) && sv_derived_from(dsv, "Apache2::Directive")) {
+        IV tmp = SvIV((SV*)SvRV(dsv));
+        ap_directive_t *directive = INT2PTR(ap_directive_t *, tmp);
+        if (directive) {
+            filename = directive->filename;
+            svav_parms.skip = directive->line_num - 1;
+        }
+    }
+
+    parms.config_file = ap_pcfg_open_custom(p, filename,
                                             &svav_parms, NULL,
                                             svav_getstr, NULL);
 
Index: src/modules/perl/modperl_cmd.c
===================================================================
--- src/modules/perl/modperl_cmd.c	(revision 422775)
+++ src/modules/perl/modperl_cmd.c	(working copy)
@@ -559,6 +559,7 @@
 
     {
         SV *server = MP_PERLSECTIONS_SERVER_SV;
+        SV *dsv = MP_PERLSECTIONS_DIRECTIVE_SV;
         SV *code = newSVpv(arg, 0);
         GV *gv = gv_fetchpv("0", TRUE, SVt_PV);
         ENTER;SAVETMPS;
@@ -567,6 +568,7 @@
         TAINT_NOT; /* XXX: temp workaround, see my p5p post */
 #endif
         sv_setref_pv(server, "Apache2::ServerRec", (void*)s);
+        sv_setref_pv(dsv, "Apache2::Directive", (void*)directive);
         sv_setpv_mg(GvSV(gv), directive->filename);
         eval_sv(code, G_SCALAR|G_KEEPERR);
         SvREFCNT_dec(code);
Index: lib/Apache2/PerlSections.pm
===================================================================
--- lib/Apache2/PerlSections.pm	(revision 422775)
+++ lib/Apache2/PerlSections.pm	(working copy)
@@ -41,6 +41,7 @@
 my @saved;
 sub save       { return $Apache2::PerlSections::Save }
 sub server     { return $Apache2::PerlSections::Server }
+sub directive  { return $Apache2::PerlSections::Directive }
 sub saved      { return @saved }
 
 sub handler : method {

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to