From: Dave Mitchell Date: Mon, 23 Apr 2007 23:01:18 +0000 (+0000) Subject: eliminate some uses of PL_linestr in perl.c X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=009d90df4e17a4157d8fe825678a18dc3e97d437;p=p5sagit%2Fp5-mst-13.2.git eliminate some uses of PL_linestr in perl.c p4raw-id: //depot/perl@31046 --- diff --git a/embed.fnc b/embed.fnc index a4c97d4..af6004c 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1250,7 +1250,7 @@ s |void |Slab_to_rw |NN void *op #endif #if defined(PERL_IN_PERL_C) || defined(PERL_DECL_PROT) -s |void |find_beginning +s |void |find_beginning |NN SV* linestr_sv s |void |forbid_setid |const char flag|const int suidscript s |void |incpush |NULLOK const char *dir|bool addsubdirs|bool addoldvers|bool usesep|bool canrelocate s |void |init_interp @@ -1266,7 +1266,7 @@ s |int |open_script |NN const char *scriptname|bool dosearch \ s |void |usage |NN const char *name s |void |validate_suid |NN const char *validarg \ |NN const char *scriptname|int fdscript \ - |int suidscript + |int suidscript|NN SV* linestr_sv # if defined(IAMSUID) s |int |fd_on_nosuid_fs|int fd # endif diff --git a/embed.h b/embed.h index 2fea714..ebdb618 100644 --- a/embed.h +++ b/embed.h @@ -3502,7 +3502,7 @@ #endif #if defined(PERL_IN_PERL_C) || defined(PERL_DECL_PROT) #ifdef PERL_CORE -#define find_beginning() S_find_beginning(aTHX) +#define find_beginning(a) S_find_beginning(aTHX_ a) #define forbid_setid(a,b) S_forbid_setid(aTHX_ a,b) #define incpush(a,b,c,d,e) S_incpush(aTHX_ a,b,c,d,e) #define init_interp() S_init_interp(aTHX) @@ -3515,7 +3515,7 @@ #define nuke_stacks() S_nuke_stacks(aTHX) #define open_script(a,b,c,d) S_open_script(aTHX_ a,b,c,d) #define usage(a) S_usage(aTHX_ a) -#define validate_suid(a,b,c,d) S_validate_suid(aTHX_ a,b,c,d) +#define validate_suid(a,b,c,d,e) S_validate_suid(aTHX_ a,b,c,d,e) #endif # if defined(IAMSUID) #ifdef PERL_CORE diff --git a/perl.c b/perl.c index ca4ebb4..54b2894 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; diff --git a/proto.h b/proto.h index c769d30..fdfbc98 100644 --- a/proto.h +++ b/proto.h @@ -3373,7 +3373,9 @@ STATIC void S_Slab_to_rw(pTHX_ void *op) #endif #if defined(PERL_IN_PERL_C) || defined(PERL_DECL_PROT) -STATIC void S_find_beginning(pTHX); +STATIC void S_find_beginning(pTHX_ SV* linestr_sv) + __attribute__nonnull__(pTHX_1); + STATIC void S_forbid_setid(pTHX_ const char flag, const int suidscript); STATIC void S_incpush(pTHX_ const char *dir, bool addsubdirs, bool addoldvers, bool usesep, bool canrelocate); STATIC void S_init_interp(pTHX); @@ -3396,9 +3398,10 @@ STATIC int S_open_script(pTHX_ const char *scriptname, bool dosearch, SV *sv, in STATIC void S_usage(pTHX_ const char *name) __attribute__nonnull__(pTHX_1); -STATIC void S_validate_suid(pTHX_ const char *validarg, const char *scriptname, int fdscript, int suidscript) +STATIC void S_validate_suid(pTHX_ const char *validarg, const char *scriptname, int fdscript, int suidscript, SV* linestr_sv) __attribute__nonnull__(pTHX_1) - __attribute__nonnull__(pTHX_2); + __attribute__nonnull__(pTHX_2) + __attribute__nonnull__(pTHX_5); # if defined(IAMSUID) STATIC int S_fd_on_nosuid_fs(pTHX_ int fd);