parse.y: unindent continued line
* parse.y (tokadd_string): stop at continued line in dedented here documents, to dedent for each lines before removing escaped newlines. [ruby-core:86236] [Bug #14621] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bc7e5fcb32
commit
491f523ab1
10
parse.y
10
parse.y
@ -5642,7 +5642,14 @@ tokadd_string(struct parser_params *p,
|
|||||||
switch (c) {
|
switch (c) {
|
||||||
case '\n':
|
case '\n':
|
||||||
if (func & STR_FUNC_QWORDS) break;
|
if (func & STR_FUNC_QWORDS) break;
|
||||||
if (func & STR_FUNC_EXPAND) continue;
|
if (func & STR_FUNC_EXPAND) {
|
||||||
|
if (!(func & STR_FUNC_INDENT) || (p->heredoc_indent < 0))
|
||||||
|
continue;
|
||||||
|
if (c == term) {
|
||||||
|
c = '\\';
|
||||||
|
goto terminate;
|
||||||
|
}
|
||||||
|
}
|
||||||
tokadd(p, '\\');
|
tokadd(p, '\\');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -5723,6 +5730,7 @@ tokadd_string(struct parser_params *p,
|
|||||||
}
|
}
|
||||||
tokadd(p, c);
|
tokadd(p, c);
|
||||||
}
|
}
|
||||||
|
terminate:
|
||||||
if (enc) *encp = enc;
|
if (enc) *encp = enc;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -721,6 +721,12 @@ e"
|
|||||||
assert_dedented_heredoc(expected, result)
|
assert_dedented_heredoc(expected, result)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_dedented_heredoc_continued_line
|
||||||
|
result = " 1\\\n" " 2\n"
|
||||||
|
expected = "1\\\n" "2\n"
|
||||||
|
assert_dedented_heredoc(expected, result)
|
||||||
|
end
|
||||||
|
|
||||||
def test_lineno_after_heredoc
|
def test_lineno_after_heredoc
|
||||||
bug7559 = '[ruby-dev:46737]'
|
bug7559 = '[ruby-dev:46737]'
|
||||||
expected, _, actual = __LINE__, <<eom, __LINE__
|
expected, _, actual = __LINE__, <<eom, __LINE__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user