From 63fac511984d61a7398a5a46e3c57c67522ba9a8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 9 Dec 2021 00:15:54 +0900 Subject: [PATCH 1/2] Get rid of ruby-mode.el confusions --- lib/rdoc/parser/c.rb | 3 ++- test/rdoc/test_rdoc_parser_ruby.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb index b89aaa6dcc..a09d046038 100644 --- a/lib/rdoc/parser/c.rb +++ b/lib/rdoc/parser/c.rb @@ -1025,7 +1025,8 @@ def handle_method(type, var_name, meth_name, function, param_count, elsif p_count == -1 then # argc, argv rb_scan_args body else - "(#{(1..p_count).map { |i| "p#{i}" }.join ', '})" + args = (1..p_count).map { |i| "p#{i}" } + "(#{args.join ', '})" end diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb index 337cf9ea1a..ceb2dbeac2 100644 --- a/test/rdoc/test_rdoc_parser_ruby.rb +++ b/test/rdoc/test_rdoc_parser_ruby.rb @@ -921,7 +921,7 @@ def test_parse_class_lower_name_warning @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment end err = stds[1] - assert_match(/Expected class name or '<<'\. Got/, err) + assert_match(/Expected class name or '<<\'\. Got/, err) end def test_parse_syntax_error_code From 45e33c4b8567d638dd53f4c9fe366cddd837b49c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 8 Dec 2021 23:54:19 +0900 Subject: [PATCH 2/2] Simplify attribute exclusiveness conditions --- lib/rdoc/markup/attribute_manager.rb | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/lib/rdoc/markup/attribute_manager.rb b/lib/rdoc/markup/attribute_manager.rb index 50764510f3..6843e6c3d0 100644 --- a/lib/rdoc/markup/attribute_manager.rb +++ b/lib/rdoc/markup/attribute_manager.rb @@ -147,13 +147,7 @@ def convert_attrs(str, attrs, exclusive = false) def convert_attrs_matching_word_pairs(str, attrs, exclusive) # first do matching ones tags = @matching_word_pairs.select { |start, bitmap| - if exclusive && exclusive?(bitmap) - true - elsif !exclusive && !exclusive?(bitmap) - true - else - false - end + exclusive == exclusive?(bitmap) }.keys return if tags.empty? all_tags = @matching_word_pairs.keys @@ -176,11 +170,7 @@ def convert_attrs_word_pair_map(str, attrs, exclusive) # then non-matching unless @word_pair_map.empty? then @word_pair_map.each do |regexp, attr| - if !exclusive - next if exclusive?(attr) - else - next if !exclusive?(attr) - end + next unless exclusive == exclusive?(attr) 1 while str.gsub!(regexp) { |orig| updated = attrs.set_attrs($`.length + $1.length, $2.length, attr) if updated @@ -198,13 +188,7 @@ def convert_attrs_word_pair_map(str, attrs, exclusive) def convert_html(str, attrs, exclusive = false) tags = @html_tags.select { |start, bitmap| - if exclusive && exclusive?(bitmap) - true - elsif !exclusive && !exclusive?(bitmap) - true - else - false - end + exclusive == exclusive?(bitmap) }.keys.join '|' 1 while str.gsub!(/<(#{tags})>(.*?)<\/\1>/i) { |orig| @@ -221,11 +205,7 @@ def convert_html(str, attrs, exclusive = false) def convert_regexp_handlings str, attrs, exclusive = false @regexp_handlings.each do |regexp, attribute| - if exclusive - next if !exclusive?(attribute) - else - next if exclusive?(attribute) - end + next unless exclusive == exclusive?(attribute) str.scan(regexp) do capture = $~.size == 1 ? 0 : 1