This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix line numbers inside here-docs
A previous commit put the number of lines in a here-doc in a separ-
ate parser field, which was added on to the line number at the next
CopLINE_inc (actually COPLINE_INC_WITH_HERELINES, now used through-
out toke.c).
Code interpolated inside the here-doc was picking up that value,
throwing line numbers off.
Before that, they were already off by one.
This commit fixes both.
I removed the CLINE from S_scan_heredoc and stopped using TERM (which
uses CLINE) for here-docs. CLINE sets PL_copline, which is used to
pass a specific line number to newSTATEOP, which may or may not be the
same number as CopLINE(PL_curcop). newSTATEOP grabs that number and
sets PL_copline to -1 (aka NOLINE). I assume this was used to make
the statement containing the <<foo marker have the right line number.
But it didn’t fully work out, as subsequent statements on the same
line had the wrong number. That I fixed a few commits ago when I
introduced herelines, making CopLINE(PL_curcop) have the right line
number for that line. So the CLINE is not actually necessary anymore.
It was causing a problem also with the first statement inside the
heredoc (in ${...}), which would ‘steal’ the line number of the
<<foo marker.
This also means that <FH> and <.*> no longer do CLINE, but it is not
necessary, as they cannot span multiple lines.