ruby-changes:56044
From: Nobuyoshi <ko1@a...>
Date: Fri, 7 Jun 2019 18:58:52 +0900 (JST)
Subject: [ruby-changes:56044] Nobuyoshi Nakada: 6566919176 (trunk): ripper_state_lex.rb: chomp CR
https://git.ruby-lang.org/ruby.git/commit/?id=6566919176 From 6566919176834efb47ea717967669ca83eb78347 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 7 Jun 2019 18:45:49 +0900 Subject: ripper_state_lex.rb: chomp CR * lib/rdoc/parser/ripper_state_lex.rb (RDoc::Parser::RipperStateLex): chomp newline, including CR, from here document terminator. Closes: ruby/rdoc#694 Closes: ruby/rdoc#697 Closes: ruby/rdoc#705 diff --git a/lib/rdoc/parser/ripper_state_lex.rb b/lib/rdoc/parser/ripper_state_lex.rb index cc7a879..5492f08 100644 --- a/lib/rdoc/parser/ripper_state_lex.rb +++ b/lib/rdoc/parser/ripper_state_lex.rb @@ -494,7 +494,8 @@ class RDoc::Parser::RipperStateLex https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/ripper_state_lex.rb#L494 private def heredoc_end?(name, indent, tk) result = false if :on_heredoc_end == tk[:kind] then - tk_name = (indent ? tk[:text].gsub(/^ *(.+)\n?$/, '\1') : tk[:text].gsub(/\n\z/, '')) + tk_name = tk[:text].chomp + tk_name.lstrip! if indent if name == tk_name result = true end diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb index 8188318..97abafc 100644 --- a/test/rdoc/test_rdoc_parser_ruby.rb +++ b/test/rdoc/test_rdoc_parser_ruby.rb @@ -2914,6 +2914,21 @@ EXPECTED https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_parser_ruby.rb#L2914 assert_equal expected, markup_code end + def test_parse_heredoc_end + code = "A = <<eos\n""OK\n""eos\n" + util_parser code + @parser.parse_statements @top_level + @parser.scan + c = @top_level.classes.first.constants.first + assert_equal("A", c.name) + + util_parser code.gsub(/$/, "\r") + @parser.parse_statements @top_level + @parser.scan + c = @top_level.classes.first.constants.first + assert_equal("A", c.name) + end + def test_parse_statements_method_oneliner_with_regexp util_parser <<RUBY class Foo -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/