[Bug #20474] Keep spaces in leading blank line

This commit is contained in:
Nobuyoshi Nakada 2024-05-08 19:25:37 +09:00
parent 841b45a442
commit 5bb656e4f0
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
2 changed files with 15 additions and 1 deletions

View File

@ -8578,6 +8578,10 @@ parser_update_heredoc_indent(struct parser_params *p, int c)
}
p->heredoc_line_indent = -1;
}
else {
/* Whitespace only line has no indentation */
p->heredoc_line_indent = 0;
}
}
return FALSE;
}

View File

@ -889,6 +889,16 @@ e"
assert_dedented_heredoc(expect, result)
end
def test_dedented_heredoc_with_leading_blank_line
# the blank line has six leading spaces
result = " \n" \
" b\n"
expect = " \n" \
"b\n"
assert_dedented_heredoc(expect, result)
end
def test_dedented_heredoc_with_blank_more_indented_line_escaped
result = " a\n" \
"\\ \\ \\ \\ \\ \\ \n" \
@ -996,7 +1006,7 @@ eom
end
def test_dedented_heredoc_concatenation
assert_equal("\n0\n1", eval("<<~0 '1'\n \n0\#{}\n0"))
assert_equal(" \n0\n1", eval("<<~0 '1'\n \n0\#{}\n0"))
end
def test_heredoc_mixed_encoding