parse.y (heredoc_treat_nextline): simplify the logic using append().

This commit is contained in:
Yukihiro "Matz" Matsumoto
2022-06-06 07:57:31 +09:00
parent 4c92636684
commit 9cc9c9fe63
2 changed files with 1052 additions and 1080 deletions
+6 -20
View File
@@ -1376,34 +1376,20 @@ heredoc_treat_nextline(parser_state *p)
if (p->heredocs_from_nextline == NULL)
return;
if (p->parsing_heredoc == NULL) {
node *n;
n = p->all_heredocs;
if (n) {
while (n->cdr)
n = n->cdr;
n->cdr = p->heredocs_from_nextline;
}
else {
p->all_heredocs = p->heredocs_from_nextline;
}
p->all_heredocs = append(p->all_heredocs, p->heredocs_from_nextline);
}
else {
node *n, *m;
m = p->heredocs_from_nextline;
while (m->cdr)
m = m->cdr;
n = p->all_heredocs;
mrb_assert(n != NULL);
if (n == p->parsing_heredoc) {
m->cdr = n;
p->all_heredocs = p->heredocs_from_nextline;
if (p->all_heredocs == p->parsing_heredoc) {
p->all_heredocs = append(p->heredocs_from_nextline, p->all_heredocs);
}
else {
node *n = p->all_heredocs;
mrb_assert(n != NULL);
append(p->heredocs_from_nextline, p->parsing_heredoc);
while (n->cdr != p->parsing_heredoc) {
n = n->cdr;
mrb_assert(n != NULL);
}
m->cdr = n->cdr;
n->cdr = p->heredocs_from_nextline;
}
}
File diff suppressed because it is too large Load Diff