Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
yui-knk committed Oct 10, 2023
1 parent c979d70 commit cd4d7a1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -8804,15 +8804,16 @@ dedent_string(struct parser_params *p, VALUE string, int width)
static NODE *
heredoc_dedent(struct parser_params *p, NODE *root)
{
NODE *node, *str_node, *prev_node;
NODE *node, *str_node, **prev_node;
int indent = p->heredoc_indent;
VALUE prev_lit = 0;

if (indent <= 0) return root;
p->heredoc_indent = 0;
if (!root) return root;

prev_node = node = str_node = root;
node = str_node = root;
prev_node = &node;
if (nd_type_p(root, NODE_LIST)) str_node = RNODE_LIST(root)->nd_head;

while (str_node) {
Expand All @@ -8830,16 +8831,16 @@ heredoc_dedent(struct parser_params *p, NODE *root)
NODE *end = RNODE_LIST(node)->as.nd_end;
node = RNODE_LIST(prev_node)->nd_next = RNODE_LIST(node)->nd_next;
if (!node) {
if (nd_type_p(prev_node, NODE_DSTR))
prev_node = dstr2str(p, prev_node);
if (nd_type_p(*prev_node, NODE_DSTR))
*prev_node = dstr2str(p, *prev_node);
break;
}
RNODE_LIST(node)->as.nd_end = end;
goto next_str;
}

str_node = 0;
while ((node = RNODE_LIST(prev_node = node)->nd_next) != 0) {
while ((node = RNODE_LIST(prev_node = &node)->nd_next) != 0) {
next_str:
if (!nd_type_p(node, NODE_LIST)) break;
if ((str_node = RNODE_LIST(node)->nd_head) != 0) {
Expand Down

0 comments on commit cd4d7a1

Please sign in to comment.