From 2d592329e05f3671632e7def1b9164b6073e618c Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 5 Dec 2017 08:50:14 +0000 Subject: [PATCH] node.c: FIELD_BLOCK * node.c (COMPOUND_FIELD, FIELD_BLOCK): moved block outside arguments like as SIMPLE_FIELD. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- node.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/node.c b/node.c index fed53b8dd0..5fa5e1fa50 100644 --- a/node.c +++ b/node.c @@ -32,18 +32,12 @@ #define D_NULL_NODE (A_INDENT, A("(null node)\n")) #define D_NODE_HEADER(node) (A_INDENT, A_NODE_HEADER(node, "\n")) -#define COMPOUND_FIELD(len, name, block) \ - do { \ - D_FIELD_HEADER((len), (name), "\n"); \ - D_INDENT; \ - block; \ - D_DEDENT; \ - } while (0) +#define COMPOUND_FIELD(len, name) \ + FIELD_BLOCK((D_FIELD_HEADER((len), (name), "\n"), D_INDENT), D_DEDENT) -#define COMPOUND_FIELD1(name, ann, block) \ +#define COMPOUND_FIELD1(name, ann) \ COMPOUND_FIELD(FIELD_NAME_LEN(name, ann), \ - FIELD_NAME_DESC(name, ann), \ - block) + FIELD_NAME_DESC(name, ann)) #define FIELD_NAME_DESC(name, ann) name " (" ann ")" #define FIELD_NAME_LEN(name, ann) (int)( \ @@ -51,9 +45,12 @@ rb_strlen_lit(FIELD_NAME_DESC(name, ann)) : \ rb_strlen_lit(name)) #define SIMPLE_FIELD(len, name) \ - for (D_FIELD_HEADER((len), (name), " "), field_flag = 1; \ + FIELD_BLOCK(D_FIELD_HEADER((len), (name), " "), A("\n")) + +#define FIELD_BLOCK(init, reset) \ + for (init, field_flag = 1; \ field_flag; /* should be optimized away */ \ - A("\n"), field_flag = 0) + reset, field_flag = 0) #define SIMPLE_FIELD1(name, ann) SIMPLE_FIELD(FIELD_NAME_LEN(name, ann), FIELD_NAME_DESC(name, ann)) #define F_CUSTOM1(name, ann) SIMPLE_FIELD1(#name, ann) @@ -65,9 +62,9 @@ #define F_MSG(name, ann, desc) SIMPLE_FIELD1(#name, ann) A(desc) #define F_NODE(name, ann) \ - COMPOUND_FIELD1(#name, ann, dump_node(buf, indent, comment, node->name)) + COMPOUND_FIELD1(#name, ann) {dump_node(buf, indent, comment, node->name);} #define F_OPTION(name, ann) \ - COMPOUND_FIELD1(#name, ann, dump_option(buf, indent, node->name)) + COMPOUND_FIELD1(#name, ann) {dump_option(buf, indent, node->name);} #define ANN(ann) \ if (comment) { \