summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-03-05 18:14:47 +0000
committerNicholas Clark <nick@ccl4.org>2011-03-05 18:14:47 +0000
commit59d6f6a4c05afa7f69dc616d7a7f7446ceb5433a (patch)
tree4fcd0d4434cb6e6f016fd87450f6a2df9a602c3f /perl.c
parent816005240f1a3b9989c940e630e829048597537c (diff)
downloadperl-59d6f6a4c05afa7f69dc616d7a7f7446ceb5433a.tar.gz
Avoid miniperl SEGVing when processing -I on the #! line
A side-effect of change 3185893b8dec1062 was to force av in S_incpush() to be NULL, whilst other flag variables were still set as if it were non-NULL, for certain cases, only when compiled with -DPERL_IS_MINIPERL The "obvious" fix is to also set all the flag variables to 0 under -DPERL_IS_MINIPERL, to make everything consistent. However, this confuses (at least) the local version of gcc, which issues warnings about passing a NULL value (av, known always to be NULL) as a not-NULL parameter, despite the fact that all the relevant calls are inside blocks which are actually dead code, due to the if() conditions being const variables set to 0 under -DPERL_IS_MINIPERL. So to avoid future bug reports about compiler warnings, the least worst thing to do seems to be to use #ifndef to use the pre-processor to eliminate the dead code, and related variables.
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/perl.c b/perl.c
index 127c2d4439..dd557af42a 100644
--- a/perl.c
+++ b/perl.c
@@ -4357,6 +4357,7 @@ S_init_perllib(pTHX)
# define PERLLIB_MANGLE(s,n) (s)
#endif
+#ifndef PERL_IS_MINIPERL
/* Push a directory onto @INC if it exists.
Generate a new SV if we do this, to save needing to copy the SV we push
onto @INC */
@@ -4378,18 +4379,16 @@ S_incpush_if_exists(pTHX_ AV *const av, SV *dir, SV *const stem)
}
return dir;
}
+#endif
STATIC void
S_incpush(pTHX_ const char *const dir, STRLEN len, U32 flags)
{
dVAR;
+#ifndef PERL_IS_MINIPERL
const U8 using_sub_dirs
-#ifdef PERL_IS_MINIPERL
- = 0;
-#else
= (U8)flags & (INCPUSH_ADD_VERSIONED_SUB_DIRS
|INCPUSH_ADD_ARCHONLY_SUB_DIRS|INCPUSH_ADD_OLD_VERS);
-#endif
const U8 add_versioned_sub_dirs
= (U8)flags & INCPUSH_ADD_VERSIONED_SUB_DIRS;
const U8 add_archonly_sub_dirs
@@ -4397,6 +4396,7 @@ S_incpush(pTHX_ const char *const dir, STRLEN len, U32 flags)
#ifdef PERL_INC_VERSION_LIST
const U8 addoldvers = (U8)flags & INCPUSH_ADD_OLD_VERS;
#endif
+#endif
const U8 canrelocate = (U8)flags & INCPUSH_CAN_RELOCATE;
const U8 unshift = (U8)flags & INCPUSH_UNSHIFT;
const U8 push_basedir = (flags & INCPUSH_NOT_BASEDIR) ? 0 : 1;
@@ -4416,7 +4416,9 @@ S_incpush(pTHX_ const char *const dir, STRLEN len, U32 flags)
pushing. Hence to make it work, need to push the architecture
(etc) libraries onto a temporary array, then "unshift" that onto
the front of @INC. */
+#ifndef PERL_IS_MINIPERL
AV *const av = (using_sub_dirs) ? (unshift ? newAV() : inc) : NULL;
+#endif
if (len) {
/* I am not convinced that this is valid when PERLLIB_MANGLE is
@@ -4543,6 +4545,7 @@ S_incpush(pTHX_ const char *const dir, STRLEN len, U32 flags)
}
#endif
}
+#ifndef PERL_IS_MINIPERL
/*
* BEFORE pushing libdir onto @INC we may first push version- and
* archname-specific sub-directories.
@@ -4586,9 +4589,10 @@ S_incpush(pTHX_ const char *const dir, STRLEN len, U32 flags)
assert (SvREFCNT(subdir) == 1);
SvREFCNT_dec(subdir);
}
-
+#endif /* !PERL_IS_MINIPERL */
/* finally add this lib directory at the end of @INC */
if (unshift) {
+#ifndef PERL_IS_MINIPERL
U32 extra = av_len(av) + 1;
av_unshift(inc, extra + push_basedir);
if (push_basedir)
@@ -4607,6 +4611,7 @@ S_incpush(pTHX_ const char *const dir, STRLEN len, U32 flags)
av_store(inc, extra, SvREFCNT_inc(*av_fetch(av, extra, FALSE)));
}
SvREFCNT_dec(av);
+#endif
}
else if (push_basedir) {
av_push(inc, libdir);