Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
toke.c: factor out static yyl_safe_bareword()
  • Loading branch information
arc committed Nov 4, 2019
commit f5417bd96886c039469e82f67f4f10c44e904b84
34 changes: 20 additions & 14 deletions toke.c
Original file line number Diff line number Diff line change
Expand Up @@ -7094,6 +7094,24 @@ yyl_fatcomma(pTHX_ char *s, STRLEN len)
TERM(BAREWORD);
}

static int
yyl_safe_bareword(pTHX_ char *s, const char lastchar, const bool saw_infix_sigil)
{
if ((lastchar == '*' || lastchar == '%' || lastchar == '&')
&& saw_infix_sigil)
{
Perl_ck_warner_d(aTHX_ packWARN(WARN_AMBIGUOUS),
"Operator or semicolon missing before %c%" UTF8f,
lastchar,
UTF8fARG(UTF, strlen(PL_tokenbuf),
PL_tokenbuf));
Perl_ck_warner_d(aTHX_ packWARN(WARN_AMBIGUOUS),
"Ambiguous use of %c resolved as operator %c",
lastchar, lastchar);
}
TOKEN(BAREWORD);
}

static int
yyl_try(pTHX_ char initial_state, char *s, STRLEN len,
I32 orig_keyword, GV *gv, GV **gvp,
Expand Down Expand Up @@ -7795,7 +7813,7 @@ yyl_try(pTHX_ char initial_state, char *s, STRLEN len,

/* And if "Foo::", then that's what it certainly is. */
if (safebw)
goto safe_bareword;
return yyl_safe_bareword(aTHX_ s, lastchar, saw_infix_sigil);

if (!off)
{
Expand Down Expand Up @@ -8031,19 +8049,7 @@ yyl_try(pTHX_ char initial_state, char *s, STRLEN len,
}
op_free(rv2cv_op);

safe_bareword:
if ((lastchar == '*' || lastchar == '%' || lastchar == '&')
&& saw_infix_sigil) {
Perl_ck_warner_d(aTHX_ packWARN(WARN_AMBIGUOUS),
"Operator or semicolon missing before %c%" UTF8f,
lastchar,
UTF8fARG(UTF, strlen(PL_tokenbuf),
PL_tokenbuf));
Perl_ck_warner_d(aTHX_ packWARN(WARN_AMBIGUOUS),
"Ambiguous use of %c resolved as operator %c",
lastchar, lastchar);
}
TOKEN(BAREWORD);
return yyl_safe_bareword(aTHX_ s, lastchar, saw_infix_sigil);
}

case KEY___FILE__:
Expand Down