diff --git a/embed.fnc b/embed.fnc index 2123d01ffad0..6f98a039112d 100644 --- a/embed.fnc +++ b/embed.fnc @@ -6078,7 +6078,7 @@ RS |SV * |get_and_check_backslash_N_name_wrapper \ |NN const char * const e S |void |incline |NN const char *s \ |NN const char *end -S |int |intuit_method |NN char *s \ +S |int |intuit_method |NN char *start \ |NULLOK SV *ioname \ |NULLOK NOCHECK CV *cv S |int |intuit_more |NN char *s \ diff --git a/proto.h b/proto.h index 922ada10d42d..da25456df112 100644 --- a/proto.h +++ b/proto.h @@ -9422,9 +9422,9 @@ S_incline(pTHX_ const char *s, const char *end); assert(s); assert(end) STATIC int -S_intuit_method(pTHX_ char *s, SV *ioname, CV *cv); +S_intuit_method(pTHX_ char *start, SV *ioname, CV *cv); # define PERL_ARGS_ASSERT_INTUIT_METHOD \ - assert(s) + assert(start) STATIC int S_intuit_more(pTHX_ char *s, char *e); diff --git a/toke.c b/toke.c index 90a36f6882d9..8c7567580841 100644 --- a/toke.c +++ b/toke.c @@ -4774,6 +4774,11 @@ S_intuit_more(pTHX_ char *s, char *e) STATIC int S_intuit_method(pTHX_ char *start, SV *ioname, CV *cv) { + PERL_ARGS_ASSERT_INTUIT_METHOD; + + if (!FEATURE_INDIRECT_IS_ENABLED) + return 0; + char *s = start + (*start == '$'); char tmpbuf[sizeof PL_tokenbuf]; STRLEN len; @@ -4785,11 +4790,6 @@ S_intuit_method(pTHX_ char *start, SV *ioname, CV *cv) GV * const gv = ioname ? gv_fetchsv(ioname, GV_NOADD_NOINIT, SVt_PVCV) : NULL; - PERL_ARGS_ASSERT_INTUIT_METHOD; - - if (!FEATURE_INDIRECT_IS_ENABLED) - return 0; - if (gv && SvTYPE(gv) == SVt_PVGV && GvIO(gv)) return 0; if (cv && SvPOK(cv)) { @@ -5381,150 +5381,150 @@ yyl_dollar(pTHX_ char *s) PREREF(PERLY_DOLLAR); } - { - const char tmp = *s; - if (PL_lex_state == LEX_NORMAL || PL_lex_brackets) - s = skipspace(s); + const char tmp = *s; + if (PL_lex_state == LEX_NORMAL || PL_lex_brackets) + s = skipspace(s); - if ( (PL_expect != XREF || PL_oldoldbufptr == PL_last_lop) - && intuit_more(s, PL_bufend)) { - if (*s == '[') { - PL_tokenbuf[0] = '@'; - if (ckWARN(WARN_SYNTAX)) { - char *t = s+1; - - while ( t < PL_bufend ) { - if (isSPACE(*t)) { - do { t++; } while (t < PL_bufend && isSPACE(*t)); - /* consumed one or more space chars */ - } else if (*t == '$' || *t == '@') { - /* could be more than one '$' like $$ref or @$ref */ - do { t++; } while (t < PL_bufend && *t == '$'); - - /* could be an abigail style identifier like $ foo */ - while (t < PL_bufend && *t == ' ') t++; - - /* strip off the name of the var */ - Size_t advance; - while ((advance = (isWORDCHAR_lazy_if_safe(t, - PL_bufend, - UTF)))) - t += advance; - /* consumed a varname */ - } else if (isDIGIT(*t)) { - /* deal with hex constants like 0x11 */ - if (t[0] == '0' && t[1] == 'x') { - t += 2; - while (t < PL_bufend && isXDIGIT(*t)) t++; - } else { - /* deal with decimal/octal constants like 1 and 0123 */ + if ( (PL_expect != XREF || PL_oldoldbufptr == PL_last_lop) + && intuit_more(s, PL_bufend)) { + if (*s == '[') { + PL_tokenbuf[0] = '@'; + if (ckWARN(WARN_SYNTAX)) { + char *t = s+1; + + while ( t < PL_bufend ) { + if (isSPACE(*t)) { + do { t++; } while (t < PL_bufend && isSPACE(*t)); + /* consumed one or more space chars */ + } else if (*t == '$' || *t == '@') { + /* could be more than one '$' like $$ref or @$ref */ + do { t++; } while (t < PL_bufend && *t == '$'); + + /* could be an abigail style identifier like $ foo */ + while (t < PL_bufend && *t == ' ') t++; + + /* strip off the name of the var */ + Size_t advance; + while ((advance = (isWORDCHAR_lazy_if_safe(t, + PL_bufend, + UTF)))) + t += advance; + /* consumed a varname */ + } else if (isDIGIT(*t)) { + /* deal with hex constants like 0x11 */ + if (t[0] == '0' && t[1] == 'x') { + t += 2; + while (t < PL_bufend && isXDIGIT(*t)) t++; + } else { + /* deal with decimal/octal constants like 1 and + * 0123 */ + do { t++; } while (isDIGIT(*t)); + if (tsaw_infix_sigil. - On its return, we then need to set it to indicate whether the token - we just encountered was an infix operator that (if we hadn't been - expecting an operator) have been a sigil. - */ - bool expected_operator = (PL_expect == XOPERATOR); - int ret = yyl_try(aTHX_ s); - switch (pl_yylval.ival) { - case OP_BIT_AND: - case OP_MODULO: - case OP_MULTIPLY: - case OP_NBIT_AND: - if (expected_operator) { - PL_parser->saw_infix_sigil = 1; - break; - } - /* FALLTHROUGH */ - default: - PL_parser->saw_infix_sigil = 0; + /* yyl_try() and its callees might consult PL_parser->saw_infix_sigil. + On its return, we then need to set it to indicate whether the token we + just encountered was an infix operator that (if we hadn't been expecting + an operator) have been a sigil. + */ + bool expected_operator = (PL_expect == XOPERATOR); + int ret = yyl_try(aTHX_ s); + switch (pl_yylval.ival) { + case OP_BIT_AND: + case OP_MODULO: + case OP_MULTIPLY: + case OP_NBIT_AND: + if (expected_operator) { + PL_parser->saw_infix_sigil = 1; + break; } - return ret; + /* FALLTHROUGH */ + default: + PL_parser->saw_infix_sigil = 0; } + + return ret; }