Skip to content

Commit 3a214c1

Browse files
committed
Allow any single-word token upto 2 before C method implementation
Previously only unknown word `intern` is allowed between a single-word token before a C method. Now any single-word token, such as `inline` which is used for `ArithmeticSequence` in enumerator.c, is allowed instead.
1 parent aaed688 commit 3a214c1

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

lib/rdoc/parser/c.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,9 +575,8 @@ def gen_body_table file_content
575575
table = {}
576576
file_content.scan(%r{
577577
((?>/\*.*?\*/\s*)?)
578-
((?:(?:\w+)\s+)?
579-
(?:intern\s+)?VALUE\s+(\w+)
580-
\s*(?:\([^)]*\))(?:[^\);]|$))
578+
((?:\w+\s+){0,2} VALUE\s+(\w+)
579+
\s*(?:\([^\)]*\))(?:[^\);]|$))
581580
| ((?>/\*.*?\*/\s*))^\s*(\#\s*define\s+(\w+)\s+(\w+))
582581
| ^\s*\#\s*define\s+(\w+)\s+(\w+)
583582
}xm) do

test/rdoc/test_rdoc_parser_c.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,36 @@ def test_find_body_macro
13731373
assert_equal "DLL_LOCAL VALUE\nother_function() {\n}", code
13741374
end
13751375

1376+
def test_find_body_static_inline
1377+
content = <<-EOF
1378+
/*
1379+
* a comment for other_function
1380+
*/
1381+
static inline VALUE
1382+
other_function() {
1383+
}
1384+
1385+
void
1386+
Init_Foo(void) {
1387+
VALUE foo = rb_define_class("Foo", rb_cObject);
1388+
1389+
rb_define_method(foo, "my_method", other_function, 0);
1390+
}
1391+
EOF
1392+
1393+
klass = util_get_class content, 'foo'
1394+
other_function = klass.method_list.first
1395+
1396+
assert_equal 'my_method', other_function.name
1397+
assert_equal "a comment for other_function",
1398+
other_function.comment.text
1399+
assert_equal '()', other_function.params
1400+
1401+
code = other_function.token_stream.first[:text]
1402+
1403+
assert_equal "static inline VALUE\nother_function() {\n}", code
1404+
end
1405+
13761406
def test_find_modifiers_call_seq
13771407
comment = RDoc::Comment.new <<-COMMENT
13781408
call-seq:

0 commit comments

Comments
 (0)