diff options
author | Brian Fraser <fraserbn@gmail.com> | 2013-09-01 19:32:17 -0300 |
---|---|---|
committer | Brian Fraser <fraserbn@gmail.com> | 2013-09-18 05:24:43 -0300 |
commit | b5248d1e210c2a723adae8e9b7f5d17076647431 (patch) | |
tree | b3b51745c4547b0dea0ccd99cf98d31b3c918f88 | |
parent | b29f65fce68bc99d0924f63f8d8bbbe70dc63890 (diff) | |
download | perl-b5248d1e210c2a723adae8e9b7f5d17076647431.tar.gz |
toke.c, S_scan_ident(): Don't take a "end of buffer" argument, use PL_bufend
All but one of scan_ident()'s callers already passed PL_bufend as
the removed argument; The one deviant was intuit_more(), which was
setting the "end of buffer" argument, to the next close-bracket.
This commit modifies intuit_more() to temporarily set PL_bufend and
then restore it.
This was done as groundwork for the following commit, which will add
more uses of PEEKSPACE() to scan_ident() in order to fix some whitespace
and line number bugs, and PEEKSPACE() modifies PL_bufend directly
if it encounters a newline at the end of the buffer -- that last bit
being why changing intuit_more() to modify-and-restore PL_bufend is
safe, since the end of the buffer will always be a ']'
-rw-r--r-- | embed.fnc | 2 | ||||
-rw-r--r-- | embed.h | 2 | ||||
-rw-r--r-- | proto.h | 7 | ||||
-rw-r--r-- | toke.c | 30 |
4 files changed, 21 insertions, 20 deletions
@@ -2236,7 +2236,7 @@ iR |SV* |get_and_check_backslash_N_name|NN const char* s \ |NN const char* const e sR |char* |scan_formline |NN char *s sR |char* |scan_heredoc |NN char *s -s |char* |scan_ident |NN char *s|NN const char *send|NN char *dest \ +s |char* |scan_ident |NN char *s|NN char *dest \ |STRLEN destlen|I32 ck_uni sR |char* |scan_inputsymbol|NN char *start sR |char* |scan_pat |NN char *start|I32 type @@ -1635,7 +1635,7 @@ #define scan_const(a) S_scan_const(aTHX_ a) #define scan_formline(a) S_scan_formline(aTHX_ a) #define scan_heredoc(a) S_scan_heredoc(aTHX_ a) -#define scan_ident(a,b,c,d,e) S_scan_ident(aTHX_ a,b,c,d,e) +#define scan_ident(a,b,c,d) S_scan_ident(aTHX_ a,b,c,d) #define scan_inputsymbol(a) S_scan_inputsymbol(aTHX_ a) #define scan_pat(a,b) S_scan_pat(aTHX_ a,b) #define scan_str(a,b,c,d,e) S_scan_str(aTHX_ a,b,c,d,e) @@ -7413,12 +7413,11 @@ STATIC char* S_scan_heredoc(pTHX_ char *s) #define PERL_ARGS_ASSERT_SCAN_HEREDOC \ assert(s) -STATIC char* S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, I32 ck_uni) +STATIC char* S_scan_ident(pTHX_ char *s, char *dest, STRLEN destlen, I32 ck_uni) __attribute__nonnull__(pTHX_1) - __attribute__nonnull__(pTHX_2) - __attribute__nonnull__(pTHX_3); + __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SCAN_IDENT \ - assert(s); assert(send); assert(dest) + assert(s); assert(dest) STATIC char* S_scan_inputsymbol(pTHX_ char *start) __attribute__warn_unused_result__ @@ -3991,7 +3991,10 @@ S_intuit_more(pTHX_ char *s) weight -= seen[un_char] * 10; if (isWORDCHAR_lazy_if(s+1,UTF)) { int len; - scan_ident(s, send, tmpbuf, sizeof tmpbuf, FALSE); + char *tmp = PL_bufend; + PL_bufend = (char*)send; + scan_ident(s, tmpbuf, sizeof tmpbuf, FALSE); + PL_bufend = tmp; len = (int)strlen(tmpbuf); if (len > 1 && gv_fetchpvn_flags(tmpbuf, len, UTF ? SVf_UTF8 : 0, SVt_PV)) @@ -5788,7 +5791,7 @@ Perl_yylex(pTHX) case '*': if (PL_expect != XOPERATOR) { - s = scan_ident(s, PL_bufend, PL_tokenbuf, sizeof PL_tokenbuf, TRUE); + s = scan_ident(s, PL_tokenbuf, sizeof PL_tokenbuf, TRUE); PL_expect = XOPERATOR; force_ident(PL_tokenbuf, '*'); if (!*PL_tokenbuf) @@ -5824,7 +5827,7 @@ Perl_yylex(pTHX) Mop(OP_MODULO); } PL_tokenbuf[0] = '%'; - s = scan_ident(s, PL_bufend, PL_tokenbuf + 1, + s = scan_ident(s, PL_tokenbuf + 1, sizeof PL_tokenbuf - 1, FALSE); pl_yylval.ival = 0; if (!PL_tokenbuf[1]) { @@ -6332,7 +6335,7 @@ Perl_yylex(pTHX) } PL_tokenbuf[0] = '&'; - s = scan_ident(s - 1, PL_bufend, PL_tokenbuf + 1, + s = scan_ident(s - 1, PL_tokenbuf + 1, sizeof PL_tokenbuf - 1, TRUE); if (PL_tokenbuf[1]) { PL_expect = XOPERATOR; @@ -6565,7 +6568,7 @@ Perl_yylex(pTHX) if (s[1] == '#' && (isIDFIRST_lazy_if(s+2,UTF) || strchr("{$:+-@", s[2]))) { PL_tokenbuf[0] = '@'; - s = scan_ident(s + 1, PL_bufend, PL_tokenbuf + 1, + s = scan_ident(s + 1, PL_tokenbuf + 1, sizeof PL_tokenbuf - 1, FALSE); if (PL_expect == XOPERATOR) no_op("Array length", s); @@ -6577,7 +6580,7 @@ Perl_yylex(pTHX) } PL_tokenbuf[0] = '$'; - s = scan_ident(s, PL_bufend, PL_tokenbuf + 1, + s = scan_ident(s, PL_tokenbuf + 1, sizeof PL_tokenbuf - 1, FALSE); if (PL_expect == XOPERATOR) no_op("Scalar", s); @@ -6696,7 +6699,7 @@ Perl_yylex(pTHX) if (PL_expect == XOPERATOR) no_op("Array", s); PL_tokenbuf[0] = '@'; - s = scan_ident(s, PL_bufend, PL_tokenbuf + 1, sizeof PL_tokenbuf - 1, FALSE); + s = scan_ident(s, PL_tokenbuf + 1, sizeof PL_tokenbuf - 1, FALSE); pl_yylval.ival = 0; if (!PL_tokenbuf[1]) { PREREF('@'); @@ -7979,8 +7982,7 @@ Perl_yylex(pTHX) p += 3; p = PEEKSPACE(p); if (isIDFIRST_lazy_if(p,UTF)) { - p = scan_ident(p, PL_bufend, - PL_tokenbuf, sizeof PL_tokenbuf, TRUE); + p = scan_ident(p, PL_tokenbuf, sizeof PL_tokenbuf, TRUE); p = PEEKSPACE(p); } if (*p != '$') @@ -9366,7 +9368,7 @@ S_scan_word(pTHX_ char *s, char *dest, STRLEN destlen, int allow_package, STRLEN } STATIC char * -S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, I32 ck_uni) +S_scan_ident(pTHX_ char *s, char *dest, STRLEN destlen, I32 ck_uni) { dVAR; char *bracket = NULL; @@ -9414,7 +9416,7 @@ S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, I32 ck if (*s == '{') { bracket = s; s++; - while (s < send && ( SPACE_OR_TAB(*s) || *s == '\n' )) + while (s < PL_bufend && ( SPACE_OR_TAB(*s) || *s == '\n' )) s++; } @@ -9434,7 +9436,7 @@ S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, I32 ck || (((U8)(d)) <= 8 && (d) != 0) \ || (((U8)(d)) == 13)))) \ || (((U8)(d)) == toCTRL('?'))) - if (s < send + if (s < PL_bufend && (isIDFIRST_lazy_if(s, is_utf8) || VALID_LEN_ONE_IDENT(*s, is_utf8))) { if ( isCNTRL_A((U8)*s) ) { @@ -9472,7 +9474,7 @@ S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, I32 ck d += is_utf8 ? UTF8SKIP(d) : 1; parse_ident(&s, &d, e, 1, is_utf8); *d = '\0'; - while (s < send && SPACE_OR_TAB(*s)) + while (s < PL_bufend && SPACE_OR_TAB(*s)) s++; if ((*s == '[' || (*s == '{' && strNE(dest, "sub")))) { /* ${foo[0]} and ${foo{bar}} notation. */ @@ -9505,7 +9507,7 @@ S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, I32 ck *d = '\0'; } - while (s < send && ( SPACE_OR_TAB(*s) || *s == '\n' )) + while (s < PL_bufend && ( SPACE_OR_TAB(*s) || *s == '\n' )) s++; /* Expect to find a closing } after consuming any trailing whitespace. |