Re: [mp1] PERL5LIB handled backwards (mod_perl 1.27+)

[prev] [thread] [next] [Date index for 2005/02/08]

From: Gordon Lack
Subject: Re: [mp1] PERL5LIB handled backwards (mod_perl 1.27+)
Date: 10:31 on 08 Feb 2005
> >    While it now does unshift rather than push (so the entries end up at
> > the front of @INC, not the back) it does so backwards!
> >
> >   eg:
> >
> >  PerlPassEnv PERL5LIB /dir1:/dir2:/dir3
> 
> You mean, PerlSetEnv, don't you? PerlPassEnv doesn't accept values.

   Yes, I did - but you get the idea :-).

> Sounds right. Did you forget to attach the patch? :)

   No, I hadn't written it at the time.  But I have now.

> Though I'm not sure how sensitive that change is. I mean someone who have
> been relying on the current implementation might get bitten by this change.

   The same could have been said of the fix at 1.27.


   Anyway, here is a fix.  rather than a patch it's the entire code of
the small perl_inc_unshift() function in src/modules/perl/perl_util.c
(line 789pp).

   I've tested the loop logic, but not actually put this into a runnign
mod_perl.  So I've only copied the perl logic (the newSV(), sv_setpvn(),
av_unshift() and av_store() calls) from the current code.  Also, I'm not
sure what should happen to an empty PERL5LIB setting or empty parts.  By
dfault the code will add empty variables - if this is wrong just add in
the code by activating the relevant ifdefs (and remove the ifdef
sections which aren't needed).




src/modules/perl/perl_util.c: 789



void perl_inc_unshift(char *p)
{
    char *wp, *ep;

    if(!p) return;

#ifdef IGNORE_EMPTY_PERL5LIB
    if (!*p) return;
#endif

    wp = p + strlen(p);  /* Points at terminating null */
    ep = wp - 1;         /* Points at final non-null */

    while (wp >= p) {
        SV *libdir = newSV(0);
        while(!((--wp == p-1) || (*wp == PERLLIB_SEP)));
#ifdef IGNORE_EMPTY_PERL5LIB_PARTS
        if (ep == wp) {
            ep=wp-1;
            continue;
        }
#endif
        sv_setpvn(libdir, wp+1, (STRLEN)(ep-wp));
        av_unshift(GvAV(incgv), 1);
        av_store(GvAV(incgv), 0, libdir);
        ep=wp-1;
    }
}

(message missing)

Missing symbol: mod_perl2-RC3
Lack Mr G M 16:31 on 06 Jan 2005

Re: Missing symbol: mod_perl2-RC3
Stas Bekman 16:53 on 06 Jan 2005

Re: Missing symbol: mod_perl2-RC3
Gordon Lack 18:42 on 06 Jan 2005

Bug(?) in mod_perl-2 RC3
Gordon Lack 19:16 on 06 Jan 2005

Re: Bug(?) in mod_perl-2 RC3
Stas Bekman 16:36 on 10 Jan 2005

Re: Bug(?) in mod_perl-2 RC3
Gordon Lack 18:04 on 10 Jan 2005

Re: Missing symbol: mod_perl2-RC3
Stas Bekman 16:40 on 10 Jan 2005

Re: Missing symbol: mod_perl2-RC3
Gordon Lack 18:10 on 10 Jan 2005

Re: Missing symbol: mod_perl2-RC3
Gordon Lack 18:31 on 10 Jan 2005

Re: Missing symbol: mod_perl2-RC3
Stas Bekman 21:57 on 10 Jan 2005

Re: Bug(?) in mod_perl-2 RC3
Stas Bekman 22:24 on 10 Jan 2005

Re: [mp1] PERL5LIB handled backwards (mod_perl 1.27+)
Gordon Lack 10:31 on 08 Feb 2005

Generated at 11:30 on 23 Feb 2005 by mariachi v0.52