This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Skip PL_expect assignment under KEY_require
authorFather Chrysostomos <sprout@cpan.org>
Fri, 22 Aug 2014 04:44:39 +0000 (21:44 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 25 Aug 2014 02:02:56 +0000 (19:02 -0700)
Only set PL_expect here when force_word has realised there is no word
there and has not called force_next.  Setting PL_expect after a call
to force_next is useless, as force_next causes its saved value to be
restored when the next token is emitted.

Changing this may seem silly, as an unconditional assignment may even
be faster, but this will allow me to eliminate PL_lex_expect and make
PL_expect handling simpler than before.

toke.c

diff --git a/toke.c b/toke.c
index 8ac5b0b..36d41f4 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -7632,7 +7632,7 @@ Perl_yylex(pTHX)
            }
            else 
                pl_yylval.ival = 0;
-           PL_expect = XTERM;
+           if (!PL_nexttoke) PL_expect = XTERM;
            PL_bufptr = s;
            PL_last_uni = PL_oldbufptr;
            PL_last_lop_op = OP_REQUIRE;