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; return 0;
} }
bol = was_bol(p); bol = was_bol(p);
/* `heredoc_line_indent == -1` means if (!bol) {
* - "after an interpolation in the same line", or /* not beginning of line, cannot be the terminater */
* - "in a continuing line" }
*/ else if (p->heredoc_line_indent == -1) {
if (bol && /* `heredoc_line_indent == -1` means
(p->heredoc_line_indent != -1 || (p->heredoc_line_indent = 0)) && * - "after an interpolation in the same line", or
whole_match_p(p, eos, len, indent)) { * - "in a continuing line"
*/
p->heredoc_line_indent = 0;
}
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;

View file

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