[前][次][番号順一覧][スレッド一覧]

ruby-changes:43828

From: nobu <ko1@a...>
Date: Mon, 15 Aug 2016 20:31:41 +0900 (JST)
Subject: [ruby-changes:43828] nobu:r55901 (trunk): node.c: nd_alen only in the head

nobu	2016-08-15 20:31:36 +0900 (Mon, 15 Aug 2016)

  New Revision: 55901

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55901

  Log:
    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.

  Modified files:
    trunk/ChangeLog
    trunk/node.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55900)
+++ ChangeLog	(revision 55901)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Aug 15 20:31:34 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* node.c (dump_array): show nd_alen field in NODE_ARRAY only in
+	  the first node.  it is nd_end in the rest nodes.
+
 Mon Aug 15 16:41:32 2016  Kazuhiro NISHIYAMA  <zn@m...>
 
 	* appveyor.yml: Update libressl version to 2.3.7.
Index: node.c
===================================================================
--- node.c	(revision 55900)
+++ node.c	(revision 55901)
@@ -132,11 +132,30 @@ dump_option(VALUE buf, VALUE indent, VAL https://github.com/ruby/ruby/blob/trunk/node.c#L132
     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 c https://github.com/ruby/ruby/blob/trunk/node.c#L507
 	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:

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]