From: Renee Baecker Date: Thu, 25 Dec 2008 23:15:25 +0000 (+0100) Subject: [perl #6665] Different behavior using the -Idir option on the command line and inside... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ccb8f6a64f3dd06b4360bc27c194b28e6766a6ad;p=p5sagit%2Fp5-mst-13.2.git [perl #6665] Different behavior using the -Idir option on the command line and inside a perl script Adds the -Idir at the beginning of @INC. (Plus a test by rgs -- check that -I does not add directories at the end of the @INC array anymore) --- diff --git a/perl.c b/perl.c index 021f35d..deb9d38 100644 --- a/perl.c +++ b/perl.c @@ -4873,7 +4873,8 @@ S_incpush_if_exists(pTHX_ SV *dir) if (PerlLIO_stat(SvPVX_const(dir), &tmpstatbuf) >= 0 && S_ISDIR(tmpstatbuf.st_mode)) { - av_push(GvAVn(PL_incgv), dir); + av_unshift( GvAVn( PL_incgv ), 1 ); + av_store( GvAVn( PL_incgv ), 0, dir ); dir = newSV(0); } return dir; @@ -5093,8 +5094,9 @@ S_incpush(pTHX_ const char *dir, bool addsubdirs, bool addoldvers, bool usesep, #endif } - /* finally push this lib directory on the end of @INC */ - av_push(GvAVn(PL_incgv), libdir); + /* finally add this lib directory at the beginning of @INC */ + av_unshift( GvAVn( PL_incgv ), 1 ); + av_store( GvAVn( PL_incgv ), 0, libdir ); } if (subdir) { assert (SvREFCNT(subdir) == 1); diff --git a/t/run/switchI.t b/t/run/switchI.t index 41192cd..cfb0f6e 100644 --- a/t/run/switchI.t +++ b/t/run/switchI.t @@ -15,11 +15,11 @@ my $Is_VMS = $^O eq 'VMS'; my $lib; $lib = $Is_MacOS ? ':Bla:' : 'Bla'; -ok(grep { $_ eq $lib } @INC); +ok(grep { $_ eq $lib } @INC[0..($#INC-1)]); SKIP: { skip 'Double colons not allowed in dir spec', 1 if $Is_VMS; $lib = $Is_MacOS ? 'Foo::Bar:' : 'Foo::Bar'; - ok(grep { $_ eq $lib } @INC); + ok(grep { $_ eq $lib } @INC[0..($#INC-1)]); } $lib = $Is_MacOS ? ':Bla2:' : 'Bla2';