> > 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;
}
}