1
0
Fork 0
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:
Nobuyoshi Nakada 2019-05-27 00:07:05 +09:00
parent 4f2a7b8001
commit a43c637660
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 13 additions and 7 deletions

18
parse.y
View file

@ -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;

View file

@ -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