[perl #65838] Allow here-doc with no final newline
When reading a line of input while scanning a here-doc, if the line
does not end in \n, then we know we have reached the end of input. By
simply tacking a \n on to the buffer, we can meet the expectations of
the rest of the here-doc parsing code. If it turns out the delimiter
is not found on that line, it does not matter that we modified it, as
we will croak anyway.
I had to add a new flag to lex_next_chunk. Before commit
f0e67a1d2,
S_scan_heredoc would read from the stream itself, without closing any
handles. So the next time through yylex, the eof code would supply
the final implicit semicolon.
Since
f0e67a1d2, S_scan_heredoc has been calling lex_next_chunk, which
takes care of reading from the stream an supply any final ; at eof.
The here-doc parser will just get confused as a result (<<';' would
work without any terminator). The new flag tells lex_next_chunk not
to do anything at eof (not even closing handles and resetting the
parser state), but to return false and leave everything as it was.