Commit 477e5285 authored by dearblue's avatar dearblue

Replacement to function for `NODE_STR` cheking

parent 9913643e
...@@ -852,11 +852,17 @@ new_dstr(parser_state *p, node *a) ...@@ -852,11 +852,17 @@ new_dstr(parser_state *p, node *a)
return cons((node*)NODE_DSTR, a); return cons((node*)NODE_DSTR, a);
} }
static int
string_node_p(node *n)
{
return (int)((enum node_type)(intptr_t)n->car == NODE_STR);
}
static node* static node*
concat_string(parser_state *p, node *a, node *b) concat_string(parser_state *p, node *a, node *b)
{ {
if ((enum node_type)(intptr_t)a->car == NODE_STR) { if (string_node_p(a)) {
if ((enum node_type)(intptr_t)b->car == NODE_STR) { if (string_node_p(b)) {
/* a == NODE_STR && b == NODE_STR */ /* a == NODE_STR && b == NODE_STR */
size_t newlen = (size_t)a->cdr->cdr + (size_t)b->cdr->cdr; size_t newlen = (size_t)a->cdr->cdr + (size_t)b->cdr->cdr;
char *str = (char*)mrb_pool_realloc(p->pool, a->cdr->car, (size_t)a->cdr->cdr + 1, newlen + 1); char *str = (char*)mrb_pool_realloc(p->pool, a->cdr->car, (size_t)a->cdr->cdr + 1, newlen + 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment