From: Gurusamy Sarathy Date: Mon, 7 Feb 2000 09:13:10 +0000 (+0000) Subject: add compatible versions from $Config{inc_ver_list} to search X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=29d82f8db02520fbd9de7355b9f87859201d969b;p=p5sagit%2Fp5-mst-13.2.git add compatible versions from $Config{inc_ver_list} to search paths automatically (from Tom Hughes ) p4raw-id: //depot/perl@5018 --- diff --git a/lib/lib.pm b/lib/lib.pm index 879af16..e46c5fe 100644 --- a/lib/lib.pm +++ b/lib/lib.pm @@ -5,6 +5,7 @@ use Config; my $archname = $Config{'archname'}; my $ver = $Config{'version'}; +my @inc_version_list = reverse split / /, $Config{'inc_version_list'}; our @ORIG_INC = @INC; # take a handy copy of 'original' value our $VERSION = '0.5564'; @@ -23,12 +24,15 @@ sub import { Carp::carp("Parameter to use lib must be directory, not file"); } unshift(@INC, $_); + # Add any previous version directories we found at configure time + foreach my $incver (@inc_version_list) + { + unshift(@INC, "$_/$incver") if -d "$_/$incver"; + } # Put a corresponding archlib directory infront of $_ if it # looks like $_ has an archlib directory below it. - if (-d "$_/$archname") { - unshift(@INC, "$_/$archname") if -d "$_/$archname/auto"; - unshift(@INC, "$_/$archname/$ver") if -d "$_/$archname/$ver/auto"; - } + unshift(@INC, "$_/$ver") if -d "$_/$ver"; + unshift(@INC, "$_/$ver/$archname") if -d "$_/$ver/$archname"; } # remove trailing duplicates diff --git a/perl.c b/perl.c index 40ce5ca..ebb76a6 100644 --- a/perl.c +++ b/perl.c @@ -3113,15 +3113,15 @@ S_init_perllib(pTHX) incpush(PRIVLIB_EXP, FALSE); #endif -#ifdef SITEARCH_EXP - incpush(SITEARCH_EXP, FALSE); -#endif #ifdef SITELIB_EXP -#if defined(WIN32) - incpush(SITELIB_EXP, TRUE); -#else - incpush(SITELIB_EXP, FALSE); -#endif + { + char buf[MAXPATHLEN]; + + strcpy(buf,SITELIB_EXP); + if (strrchr(buf,'/')) /* XXX Hack, Configure var needed */ + *strrchr(buf,'/') = '\0'; + incpush(buf, TRUE); + } #endif #if defined(PERL_VENDORLIB_EXP) #if defined(WIN32) @@ -3186,6 +3186,10 @@ S_incpush(pTHX_ char *p, int addsubdirs) * archname-specific sub-directories. */ if (addsubdirs) { +#ifdef PERL_INC_VERSION_LIST + const char *incverlist[] = { PERL_INC_VERSION_LIST, NULL }; + const char **incver; +#endif struct stat tmpstatbuf; #ifdef VMS char *unix; @@ -3201,21 +3205,33 @@ S_incpush(pTHX_ char *p, int addsubdirs) "Failed to unixify @INC element \"%s\"\n", SvPV(libdir,len)); #endif - /* .../archname/version if -d .../archname/version/auto */ - Perl_sv_setpvf(aTHX_ subdir, "%"SVf"/%s/"PERL_FS_VER_FMT"/auto", libdir, - ARCHNAME, (int)PERL_REVISION, - (int)PERL_VERSION, (int)PERL_SUBVERSION); + /* .../version/archname if -d .../version/archname */ + Perl_sv_setpvf(aTHX_ subdir, "%"SVf"/"PERL_FS_VER_FMT"/%s", libdir, + (int)PERL_REVISION, (int)PERL_VERSION, + (int)PERL_SUBVERSION, ARCHNAME); if (PerlLIO_stat(SvPVX(subdir), &tmpstatbuf) >= 0 && S_ISDIR(tmpstatbuf.st_mode)) - av_push(GvAVn(PL_incgv), - newSVpvn(SvPVX(subdir), SvCUR(subdir) - sizeof "auto")); + av_push(GvAVn(PL_incgv), newSVsv(subdir)); - /* .../archname if -d .../archname/auto */ - Perl_sv_setpvf(aTHX_ subdir, "%"SVf"/%s/auto", libdir, ARCHNAME); + /* .../version if -d .../version */ + Perl_sv_setpvf(aTHX_ subdir, "%"SVf"/"PERL_FS_VER_FMT, libdir, + (int)PERL_REVISION, (int)PERL_VERSION, + (int)PERL_SUBVERSION); if (PerlLIO_stat(SvPVX(subdir), &tmpstatbuf) >= 0 && S_ISDIR(tmpstatbuf.st_mode)) - av_push(GvAVn(PL_incgv), - newSVpvn(SvPVX(subdir), SvCUR(subdir) - sizeof "auto")); + av_push(GvAVn(PL_incgv), newSVsv(subdir)); + +#ifdef PERL_INC_VERSION_LIST + for (incver = incverlist; *incver; incver++) + { + /* .../xxx if -d .../xxx */ + Perl_sv_setpvf(aTHX_ subdir, "%"SVf"/%s", libdir, *incver); + if (PerlLIO_stat(SvPVX(subdir), &tmpstatbuf) >= 0 && + S_ISDIR(tmpstatbuf.st_mode)) + av_push(GvAVn(PL_incgv), newSVsv(subdir)); + + } +#endif } /* finally push this lib directory on the end of @INC */