mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: broke the terminator condition down
* parse.y (here_document): broke the terminator condition down into each piece, the positional condition, resetting the dedented here-document indentation, and matching identifier. suppress a false warning by icc.
This commit is contained in:
parent
4f2a7b8001
commit
a43c637660
2 changed files with 13 additions and 7 deletions
18
parse.y
18
parse.y
|
@ -7201,13 +7201,17 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
|
|||
return 0;
|
||||
}
|
||||
bol = was_bol(p);
|
||||
/* `heredoc_line_indent == -1` means
|
||||
* - "after an interpolation in the same line", or
|
||||
* - "in a continuing line"
|
||||
*/
|
||||
if (bol &&
|
||||
(p->heredoc_line_indent != -1 || (p->heredoc_line_indent = 0)) &&
|
||||
whole_match_p(p, eos, len, indent)) {
|
||||
if (!bol) {
|
||||
/* not beginning of line, cannot be the terminater */
|
||||
}
|
||||
else if (p->heredoc_line_indent == -1) {
|
||||
/* `heredoc_line_indent == -1` means
|
||||
* - "after an interpolation in the same line", or
|
||||
* - "in a continuing line"
|
||||
*/
|
||||
p->heredoc_line_indent = 0;
|
||||
}
|
||||
else if (whole_match_p(p, eos, len, indent)) {
|
||||
dispatch_heredoc_end(p);
|
||||
heredoc_restore(p, &p->lex.strterm->u.heredoc);
|
||||
p->lex.strterm = 0;
|
||||
|
|
|
@ -753,6 +753,8 @@ e"
|
|||
\
|
||||
TEXT
|
||||
end;
|
||||
|
||||
assert_equal(" TEXT\n", eval("<<~eos\n" " \\\n" "TEXT\n" "eos\n"))
|
||||
end
|
||||
|
||||
def test_lineno_after_heredoc
|
||||
|
|
Loading…
Reference in a new issue