aboutsummaryrefslogtreecommitdiffstats
path: root/node.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-15 11:31:36 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-15 11:31:36 +0000
commit031ba57bade534aad7653342bd60277f65ed2c86 (patch)
treef5728e8b54a709c61b9218d7ce348d690e0b97e9 /node.c
parentca93ad1ac84312fdb95810bf2afe0d9b523fcc3e (diff)
downloadruby-031ba57bade534aad7653342bd60277f65ed2c86.tar.gz
node.c: nd_alen only in the head
* node.c (dump_array): show nd_alen field in NODE_ARRAY only in the first node. it is nd_end in the rest nodes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'node.c')
-rw-r--r--node.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/node.c b/node.c
index 40cb5a952a..14f9856ba5 100644
--- a/node.c
+++ b/node.c
@@ -132,11 +132,30 @@ dump_option(VALUE buf, VALUE indent, VALUE opt)
rb_hash_foreach(opt, add_option_i, (VALUE)&arg);
}
+static void dump_node(VALUE, VALUE, int, NODE *);
+static const char default_indent[] = "| ";
+
+static void
+dump_array(VALUE buf, VALUE indent, int comment, NODE *node)
+{
+ int field_flag;
+ const char *next_indent = default_indent;
+ D_NODE_HEADER(node);
+ F_LONG(nd_alen, "length");
+ F_NODE(nd_head, "element");
+ while (node->nd_next && nd_type(node->nd_next) == NODE_ARRAY) {
+ node = node->nd_next;
+ F_NODE(nd_head, "element");
+ }
+ LAST_NODE;
+ F_NODE(nd_next, "next element");
+}
+
static void
dump_node(VALUE buf, VALUE indent, int comment, NODE *node)
{
int field_flag;
- const char *next_indent = "| ";
+ const char *next_indent = default_indent;
if (!node) {
D_NULL_NODE;
@@ -488,10 +507,7 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node)
ANN("format: [ [nd_head], [nd_next].. ] (length: [nd_alen])");
ANN("example: return 1, 2, 3");
ary:
- F_LONG(nd_alen, "length");
- F_NODE(nd_head, "element");
- LAST_NODE;
- F_NODE(nd_next, "next element");
+ dump_array(buf, indent, comment, node);
break;
case NODE_ZARRAY: