From: Dave Mitchell Date: Sun, 1 Apr 2007 01:20:02 +0000 (+0000) Subject: Eliminate the use of PL_bufend outside of toke.c: X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=65b06e02d98d79674a9890d225d9bbf7b8191dbe;p=p5sagit%2Fp5-mst-13.2.git Eliminate the use of PL_bufend outside of toke.c: give Perl_scan_vstring() an explicit 'end' arg rather than using PL_bufend, and replace it with a local var in Perl_find_script() p4raw-id: //depot/perl@30820 --- diff --git a/embed.fnc b/embed.fnc index 0c856ad..a8458dd 100644 --- a/embed.fnc +++ b/embed.fnc @@ -596,7 +596,7 @@ Apa |OP* |newWHILEOP |I32 flags|I32 debuggable|NULLOK LOOP* loop \ |I32 whileline|NULLOK OP* expr|NULLOK OP* block|NULLOK OP* cont \ |I32 has_my Apa |PERL_SI*|new_stackinfo|I32 stitems|I32 cxitems -Ap |char* |scan_vstring |NN const char *vstr|NN SV *sv +Ap |char* |scan_vstring |NN const char *vstr|NN const char *end|NN SV *sv Apd |const char* |scan_version |NN const char *vstr|NN SV *sv|bool qv Apd |SV* |new_version |NN SV *ver Apd |SV* |upg_version |NN SV *ver|bool qv diff --git a/embed.h b/embed.h index 2f7cb14..9228e7b 100644 --- a/embed.h +++ b/embed.h @@ -2829,7 +2829,7 @@ #define newWHENOP(a,b) Perl_newWHENOP(aTHX_ a,b) #define newWHILEOP(a,b,c,d,e,f,g,h) Perl_newWHILEOP(aTHX_ a,b,c,d,e,f,g,h) #define new_stackinfo(a,b) Perl_new_stackinfo(aTHX_ a,b) -#define scan_vstring(a,b) Perl_scan_vstring(aTHX_ a,b) +#define scan_vstring(a,b,c) Perl_scan_vstring(aTHX_ a,b,c) #define scan_version(a,b,c) Perl_scan_version(aTHX_ a,b,c) #define new_version(a) Perl_new_version(aTHX_ a) #define upg_version(a,b) Perl_upg_version(aTHX_ a,b) diff --git a/proto.h b/proto.h index 85aa884..811730a 100644 --- a/proto.h +++ b/proto.h @@ -1663,9 +1663,10 @@ PERL_CALLCONV PERL_SI* Perl_new_stackinfo(pTHX_ I32 stitems, I32 cxitems) __attribute__malloc__ __attribute__warn_unused_result__; -PERL_CALLCONV char* Perl_scan_vstring(pTHX_ const char *vstr, SV *sv) +PERL_CALLCONV char* Perl_scan_vstring(pTHX_ const char *vstr, const char *end, SV *sv) __attribute__nonnull__(pTHX_1) - __attribute__nonnull__(pTHX_2); + __attribute__nonnull__(pTHX_2) + __attribute__nonnull__(pTHX_3); PERL_CALLCONV const char* Perl_scan_version(pTHX_ const char *vstr, SV *sv, bool qv) __attribute__nonnull__(pTHX_1) diff --git a/sv.c b/sv.c index 88dcd96..09a1772 100644 --- a/sv.c +++ b/sv.c @@ -8694,12 +8694,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV goto unknown; } vecsv = sv_newmortal(); - /* scan_vstring is expected to be called during - * tokenization, so we need to fake up the end - * of the buffer for it - */ - PL_bufend = version + veclen; - scan_vstring(version, vecsv); + scan_vstring(version, version + veclen, vecsv); vecstr = (U8*)SvPV_const(vecsv, veclen); vec_utf8 = DO_UTF8(vecsv); Safefree(version); diff --git a/toke.c b/toke.c index 96b33cb..920b6d2 100644 --- a/toke.c +++ b/toke.c @@ -12222,7 +12222,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp) case 'v': vstring: sv = newSV(5); /* preallocate storage space */ - s = scan_vstring(s,sv); + s = scan_vstring(s, PL_bufend, sv); break; } @@ -12704,28 +12704,29 @@ vstring, as well as updating the passed in sv. Function must be called like sv = newSV(5); - s = scan_vstring(s,sv); + s = scan_vstring(s,e,sv); +where s and e are the start and end of the string. The sv should already be large enough to store the vstring passed in, for performance reasons. */ char * -Perl_scan_vstring(pTHX_ const char *s, SV *sv) +Perl_scan_vstring(pTHX_ const char *s, const char *e, SV *sv) { dVAR; const char *pos = s; const char *start = s; if (*pos == 'v') pos++; /* get past 'v' */ - while (pos < PL_bufend && (isDIGIT(*pos) || *pos == '_')) + while (pos < e && (isDIGIT(*pos) || *pos == '_')) pos++; if ( *pos != '.') { /* this may not be a v-string if followed by => */ const char *next = pos; - while (next < PL_bufend && isSPACE(*next)) + while (next < e && isSPACE(*next)) ++next; - if ((PL_bufend - next) >= 2 && *next == '=' && next[1] == '>' ) { + if ((e - next) >= 2 && *next == '=' && next[1] == '>' ) { /* return string not v-string */ sv_setpvn(sv,(char *)s,pos-s); return (char *)pos; @@ -12765,13 +12766,13 @@ Perl_scan_vstring(pTHX_ const char *s, SV *sv) sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf); if (!UNI_IS_INVARIANT(NATIVE_TO_UNI(rev))) SvUTF8_on(sv); - if (pos + 1 < PL_bufend && *pos == '.' && isDIGIT(pos[1])) + if (pos + 1 < e && *pos == '.' && isDIGIT(pos[1])) s = ++pos; else { s = pos; break; } - while (pos < PL_bufend && (isDIGIT(*pos) || *pos == '_')) + while (pos < e && (isDIGIT(*pos) || *pos == '_')) pos++; } SvPOK_on(sv);