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
10
parse.y
10
parse.y
|
@ -7201,13 +7201,17 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
bol = was_bol(p);
|
bol = was_bol(p);
|
||||||
|
if (!bol) {
|
||||||
|
/* not beginning of line, cannot be the terminater */
|
||||||
|
}
|
||||||
|
else if (p->heredoc_line_indent == -1) {
|
||||||
/* `heredoc_line_indent == -1` means
|
/* `heredoc_line_indent == -1` means
|
||||||
* - "after an interpolation in the same line", or
|
* - "after an interpolation in the same line", or
|
||||||
* - "in a continuing line"
|
* - "in a continuing line"
|
||||||
*/
|
*/
|
||||||
if (bol &&
|
p->heredoc_line_indent = 0;
|
||||||
(p->heredoc_line_indent != -1 || (p->heredoc_line_indent = 0)) &&
|
}
|
||||||
whole_match_p(p, eos, len, indent)) {
|
else if (whole_match_p(p, eos, len, indent)) {
|
||||||
dispatch_heredoc_end(p);
|
dispatch_heredoc_end(p);
|
||||||
heredoc_restore(p, &p->lex.strterm->u.heredoc);
|
heredoc_restore(p, &p->lex.strterm->u.heredoc);
|
||||||
p->lex.strterm = 0;
|
p->lex.strterm = 0;
|
||||||
|
|
|
@ -753,6 +753,8 @@ e"
|
||||||
\
|
\
|
||||||
TEXT
|
TEXT
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
assert_equal(" TEXT\n", eval("<<~eos\n" " \\\n" "TEXT\n" "eos\n"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_lineno_after_heredoc
|
def test_lineno_after_heredoc
|
||||||
|
|
Loading…
Reference in a new issue