ruby-changes:43940
From: nobu <ko1@a...>
Date: Fri, 26 Aug 2016 17:39:05 +0900 (JST)
Subject: [ruby-changes:43940] nobu:r56013 (trunk): parse.y: reset indent in heredoc_dedent
nobu 2016-08-26 17:29:23 +0900 (Fri, 26 Aug 2016) New Revision: 56013 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56013 Log: parse.y: reset indent in heredoc_dedent * parse.y (parser_heredoc_dedent): reset heredoc_indent and return the dedented node. Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 56012) +++ parse.y (revision 56013) @@ -525,7 +525,7 @@ static int reg_fragment_check_gen(struct https://github.com/ruby/ruby/blob/trunk/parse.y#L525 static NODE *reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp); #define reg_named_capture_assign(regexp) reg_named_capture_assign_gen(parser,(regexp)) -static void parser_heredoc_dedent(struct parser_params*,NODE*); +static NODE *parser_heredoc_dedent(struct parser_params*,NODE*); # define heredoc_dedent(str) parser_heredoc_dedent(parser, (str)) #define get_id(id) (id) @@ -733,7 +733,7 @@ new_args_tail_gen(struct parser_params * https://github.com/ruby/ruby/blob/trunk/parse.y#L733 #define new_defined(expr) dispatch1(defined, (expr)) -static void parser_heredoc_dedent(struct parser_params*,VALUE); +static VALUE parser_heredoc_dedent(struct parser_params*,VALUE); # define heredoc_dedent(str) parser_heredoc_dedent(parser, (str)) #define FIXME 0 @@ -3894,17 +3894,13 @@ string : tCHAR https://github.com/ruby/ruby/blob/trunk/parse.y#L3894 string1 : tSTRING_BEG string_contents tSTRING_END { - heredoc_dedent($2); - heredoc_indent = 0; - $$ = new_string1($2); + $$ = new_string1(heredoc_dedent($2)); } ; xstring : tXSTRING_BEG xstring_contents tSTRING_END { - heredoc_dedent($2); - heredoc_indent = 0; - $$ = new_xstring($2); + $$ = new_xstring(heredoc_dedent($2)); } ; @@ -6506,18 +6502,18 @@ dedent_string(VALUE string, int width) https://github.com/ruby/ruby/blob/trunk/parse.y#L6502 } #ifndef RIPPER -static void +static NODE * parser_heredoc_dedent(struct parser_params *parser, NODE *root) { NODE *node, *str_node; int bol = TRUE; int indent = heredoc_indent; - if (indent <= 0) return; + if (indent <= 0) return root; + heredoc_indent = 0; + if (!root) return root; node = str_node = root; - - if (!root) return; if (nd_type(root) == NODE_ARRAY) str_node = root->nd_head; while (str_node) { @@ -6535,14 +6531,18 @@ parser_heredoc_dedent(struct parser_para https://github.com/ruby/ruby/blob/trunk/parse.y#L6531 } } } + return root; } #else /* RIPPER */ -static void +static VALUE parser_heredoc_dedent(struct parser_params *parser, VALUE array) { - if (heredoc_indent <= 0) return; + int indent = heredoc_indent; - dispatch2(heredoc_dedent, array, INT2NUM(heredoc_indent)); + if (indent <= 0) return array; + heredoc_indent = 0; + dispatch2(heredoc_dedent, array, INT2NUM(indent)); + return array; } static VALUE -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/