summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2007-04-23 23:01:18 +0000
committerDave Mitchell <davem@fdisolutions.com>2007-04-23 23:01:18 +0000
commit009d90df4e17a4157d8fe825678a18dc3e97d437 (patch)
treed0ccc7c617a586bda0cd201eaac99cc277d14d40 /perl.c
parent219f722694525406e854cc2c0ab7723f56ce7dfc (diff)
downloadperl-009d90df4e17a4157d8fe825678a18dc3e97d437.tar.gz
eliminate some uses of PL_linestr in perl.c
p4raw-id: //depot/perl@31046
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/perl.c b/perl.c
index ca4ebb4d1d..54b2894383 100644
--- a/perl.c
+++ b/perl.c
@@ -1670,8 +1670,11 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
#ifdef USE_SITECUSTOMIZE
bool minus_f = FALSE;
#endif
+ SV *linestr_sv = newSV_type(SVt_PVIV);
+
+ SvGROW(linestr_sv, 80);
+ sv_setpvn(linestr_sv,"",0);
- sv_setpvn(PL_linestr,"",0);
sv = newSVpvs(""); /* first used for -I flags */
SAVEFREESV(sv);
init_main_stash();
@@ -2115,7 +2118,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
const int fdscript
= open_script(scriptname, dosearch, sv, &suidscript);
- validate_suid(validarg, scriptname, fdscript, suidscript);
+ validate_suid(validarg, scriptname, fdscript, suidscript, linestr_sv);
#ifndef PERL_MICRO
# if defined(SIGCHLD) || defined(SIGCLD)
@@ -2145,7 +2148,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
forbid_setid('x', suidscript);
/* Hence you can't get here if suidscript >= 0 */
- find_beginning();
+ find_beginning(linestr_sv);
if (cddir && PerlDir_chdir( (char *)cddir ) < 0)
Perl_croak(aTHX_ "Can't chdir to %s",cddir);
}
@@ -2260,7 +2263,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
tmpfp = PL_rsfp;
PL_rsfp = NULL;
- lex_start(PL_linestr);
+ lex_start(linestr_sv);
PL_rsfp = tmpfp;
PL_subname = newSVpvs("main");
@@ -3891,7 +3894,7 @@ S_fd_on_nosuid_fs(pTHX_ int fd)
STATIC void
S_validate_suid(pTHX_ const char *validarg, const char *scriptname,
- int fdscript, int suidscript)
+ int fdscript, int suidscript, SV *linestr_sv)
{
dVAR;
#ifdef IAMSUID
@@ -4031,9 +4034,9 @@ S_validate_suid(pTHX_ const char *validarg, const char *scriptname,
PL_doswitches = FALSE; /* -s is insecure in suid */
/* PSz 13 Nov 03 But -s was caught elsewhere ... so unsetting it here is useless(?!) */
CopLINE_inc(PL_curcop);
- if (sv_gets(PL_linestr, PL_rsfp, 0) == NULL)
+ if (sv_gets(linestr_sv, PL_rsfp, 0) == NULL)
Perl_croak(aTHX_ "No #! line");
- linestr = SvPV_nolen_const(PL_linestr);
+ linestr = SvPV_nolen_const(linestr_sv);
/* required even on Sys V */
if (!*linestr || !linestr[1] || strnNE(linestr,"#!",2))
Perl_croak(aTHX_ "No #! line");
@@ -4300,7 +4303,7 @@ FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n");
}
STATIC void
-S_find_beginning(pTHX)
+S_find_beginning(pTHX_ SV* linestr_sv)
{
dVAR;
register char *s;
@@ -4315,7 +4318,7 @@ S_find_beginning(pTHX)
/* Since the Mac OS does not honor #! arguments for us, we do it ourselves */
while (PL_doextract || gMacPerl_AlwaysExtract) {
- if ((s = sv_gets(PL_linestr, PL_rsfp, 0)) == NULL) {
+ if ((s = sv_gets(linestr_sv, PL_rsfp, 0)) == NULL) {
if (!gMacPerl_AlwaysExtract)
Perl_croak(aTHX_ "No Perl script found in input\n");
@@ -4332,7 +4335,7 @@ S_find_beginning(pTHX)
}
#else
while (PL_doextract) {
- if ((s = sv_gets(PL_linestr, PL_rsfp, 0)) == NULL)
+ if ((s = sv_gets(linestr_sv, PL_rsfp, 0)) == NULL)
Perl_croak(aTHX_ "No Perl script found in input\n");
#endif
s2 = s;