diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-09-26 14:04:21 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-09-26 14:04:21 +0000 |
commit | a72a1c8b669f627c80c2fa5d710eb7980a143476 (patch) | |
tree | 2fe0a5115982a725a716eb6ec15b5aea105577a6 /toke.c | |
parent | 204b4d7f800e266ce239f9e434271307a9c45b3e (diff) | |
download | perl-a72a1c8b669f627c80c2fa5d710eb7980a143476.tar.gz |
CORE::require was always parsed as require().
That's because require() isn't overridable at tokenizer-level
like other overridable built-ins, but is handled by the optree
builder. So, find a way to pass the information that require()
was written as CORE::require() to Perl_ck_require. This is
done by adding a new token type REQUIRE and by adding OPf_SPECIAL
to OP_REQUIRE when it's saw as CORE::require in the program text.
This fixes bug [perl #37274] The "CORE" in CORE::require is ignored.
p4raw-id: //depot/perl@25599
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -4520,6 +4520,9 @@ Perl_yylex(pTHX) Perl_croak(aTHX_ "CORE::%s is not a keyword", PL_tokenbuf); if (tmp < 0) tmp = -tmp; + else if (tmp == KEY_require) + /* that's a way to remember we saw "CORE::" */ + orig_keyword = KEY_require; goto reserved_word; } goto just_a_word; @@ -5101,7 +5104,18 @@ Perl_yylex(pTHX) else if (*s == '<') yyerror("<> should be quotes"); } - UNI(OP_REQUIRE); + if (orig_keyword == KEY_require) { + orig_keyword = 0; + yylval.ival = 1; + } + else + yylval.ival = 0; + PL_expect = XTERM; + PL_bufptr = s; + PL_last_uni = PL_oldbufptr; + PL_last_lop_op = OP_REQUIRE; + s = skipspace(s); + return REPORT( (int)REQUIRE ); case KEY_reset: UNI(OP_RESET); |