From 4a7239ff0b409a13fa6982413ce503f8e5fa07c3 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Fri, 17 Aug 2012 14:45:29 -0700 Subject: [PATCH] [perl #114040] Allow pod in quoted constructs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When the case = in toke.c:yylex is reached and PL_lex_state is not LEX_NORMAL, that means we are in some sort of quoted construct, and the entire construct’s content is in the current line buffer (which, consequently contains more than one line). So we need to check that when encountering pod. Quoted constructs need to be treated the same way as string eval, which also puts all the code in the line buffer. --- t/comp/parser.t | 21 ++++++++++++++++++++- toke.c | 3 ++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/t/comp/parser.t b/t/comp/parser.t index d22e9b3..09f2d1c 100644 --- a/t/comp/parser.t +++ b/t/comp/parser.t @@ -3,7 +3,7 @@ # Checks if the parser behaves correctly in edge cases # (including weird syntax errors) -print "1..139\n"; +print "1..140\n"; sub failed { my ($got, $expected, $name) = @_; @@ -397,6 +397,25 @@ $_ write }).*/; +eval ' +"${; + +=pod + +=cut + +}"; +'; +is $@, "", 'pod inside string in string eval'; +"${; + +=pod + +=cut + +}"; +print "ok ", ++$test, " - pod inside string outside of string eval\n"; + sub 'Hello'_he_said (_); is prototype "Hello::_he_said", '_', 'initial tick in sub declaration'; diff --git a/toke.c b/toke.c index aecd7f1..d0c9087 100644 --- a/toke.c +++ b/toke.c @@ -6001,7 +6001,8 @@ Perl_yylex(pTHX) if (PL_expect == XSTATE && isALPHA(tmp) && (s == PL_linestart+1 || s[-2] == '\n') ) { - if (PL_in_eval && !PL_rsfp && !PL_parser->filtered) { + if ((PL_in_eval && !PL_rsfp && !PL_parser->filtered) + || PL_lex_state != LEX_NORMAL) { d = PL_bufend; while (s < d) { if (*s++ == '\n') { -- 2.7.4