diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-08-29 12:35:49 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-08-30 18:18:07 -0700 |
commit | 3328ab5af72319f76fe9be3910a8e07d38b14de2 (patch) | |
tree | f80d9a0a8a93eabee927ac638b230b97ddf11b67 /t | |
parent | a7922135a13574b7c0cd4fa4acc00114f1197ab9 (diff) | |
download | perl-3328ab5af72319f76fe9be3910a8e07d38b14de2.tar.gz |
Finish fixing here-docs in re-evals
This commit fixes here-docs in single-line re-evals in files (as
opposed to evals) and here-docs in single-line quote-like operators
inside re-evals.
In both cases, the here-doc parser has to look into an outer
lexing scope to find the here-doc body. And in both cases it
was stomping on PL_linestr (the current line buffer) while
PL_sublex_info.re_eval_start was pointing to an offset in that buffer.
(re_eval_start is used to construct the string to include in the
regexp’s stringification once the lexer reaches the end of the
re-eval.)
Fixing this entails moving re_eval_start and re_eval_str to
PL_parser->lex_shared, making the pre-localised values visible.
This is so that the code that peeks into an outer linestr buffer to
steal the here-doc body can set up re_eval_str in the right scope.
(re_eval_str is used to store the re-eval text when the here-
oc parser has no choice but to modify linestr; see also commit
db4442662555874019.)
It also entails making the stream-based parser (i.e., that reads from
an input stream) leave PL_linestr alone, instead of clobbering it and
then reconstructing part of it afterwards.
Diffstat (limited to 't')
-rw-r--r-- | t/base/lex.t | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/t/base/lex.t b/t/base/lex.t index 4c4981d94d..9868d4cf78 100644 --- a/t/base/lex.t +++ b/t/base/lex.t @@ -1,6 +1,6 @@ #!./perl -print "1..66\n"; +print "1..68\n"; $x = 'x'; @@ -326,3 +326,15 @@ END eval 'print qq ;ok 66 - eval ending with semicolon\n;' or print "not ok 66 - eval ending with semicolon\n"; + +print "not " unless qr/(?{<<END})/ eq '(?^:(?{<<END}))'; +foo +END +print "ok 67 - here-doc in single-line re-eval\n"; + +$_ = qr/(?{"${<<END}" +foo +END +})/; +print "not " unless /foo/; +print "ok 68 - here-doc in quotes in multiline re-eval\n"; |