summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-09-20 00:50:54 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-09-20 01:19:07 -0700
commit8c29fccb2d2fd2d0d9fd6074018645febe1cb943 (patch)
tree5e94aa910c68f5582c06d3f87e7768d19678ba7d
parent4aaee9b8df62149cfed9099d3b9422c6d397c274 (diff)
downloadperl-8c29fccb2d2fd2d0d9fd6074018645febe1cb943.tar.gz
Fix line nums when multiline ${expr} spans here-doc
<<end . ${ end "bar"}; warn __LINE__ # 3, not 5 This was caused by commit a49b10d0a, which make scan_ident in toke.c reallocate the parser’s current line buffer (SvPVX(PL_linestr)) to search for whitespace surrounding an identifier. In case there is an arbitrary expression, it temporarily records the line number and resets it at the end if that turns out to be the case. However, it was not resetting PL_parser->herelines, which records how many line numbers to skip when next incrementing it (to skip past here-doc bodies). So save and restore that value, too.
-rw-r--r--t/comp/parser.t10
-rw-r--r--toke.c2
2 files changed, 11 insertions, 1 deletions
diff --git a/t/comp/parser.t b/t/comp/parser.t
index 6578c74385..8fd7e85957 100644
--- a/t/comp/parser.t
+++ b/t/comp/parser.t
@@ -8,7 +8,7 @@ BEGIN {
chdir 't';
}
-print "1..167\n";
+print "1..168\n";
sub failed {
my ($got, $expected, $name) = @_;
@@ -634,5 +634,13 @@ ${;
END
check_line(627, 'line number after heredoc containing #line');
+#line 638
+<<ENE . ${
+
+ENE
+"bar"};
+check_line(642, 'line number after ${expr} surrounding heredoc body');
+
+
__END__
# Don't add new tests HERE. See note above
diff --git a/toke.c b/toke.c
index 14d9b983a3..257d69b761 100644
--- a/toke.c
+++ b/toke.c
@@ -9371,6 +9371,7 @@ STATIC char *
S_scan_ident(pTHX_ char *s, char *dest, STRLEN destlen, I32 ck_uni)
{
dVAR;
+ I32 herelines = PL_parser->herelines;
SSize_t bracket = -1;
char funny = *s++;
char *d = dest;
@@ -9552,6 +9553,7 @@ S_scan_ident(pTHX_ char *s, char *dest, STRLEN destlen, I32 ck_uni)
state such that the next thing to process is the opening { and */
s = SvPVX(PL_linestr) + bracket; /* let the parser handle it */
CopLINE_set(PL_curcop, orig_copline);
+ PL_parser->herelines = herelines;
*dest = '\0';
}
}