summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenee Baecker <renee.baecker@smart-websolutions.de>2008-12-26 00:15:25 +0100
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2008-12-26 00:15:25 +0100
commitccb8f6a64f3dd06b4360bc27c194b28e6766a6ad (patch)
tree9e08c17ffef10250fc4538f5002730c529c1d893
parent0147cd53faa57ffcd05cb0455b952fbfbe63b0b2 (diff)
downloadperl-ccb8f6a64f3dd06b4360bc27c194b28e6766a6ad.tar.gz
[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)
-rw-r--r--perl.c8
-rw-r--r--t/run/switchI.t4
2 files changed, 7 insertions, 5 deletions
diff --git a/perl.c b/perl.c
index 021f35d327..deb9d383b2 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 41192cd765..cfb0f6e949 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';