Skip to content

Commit 72c6560

Browse files
committed
Only word-ending colon separates new definition
When followed by non-space characters, rather it looks like a URL or a path name on Windows.
1 parent 1904e90 commit 72c6560

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/rdoc/parser/c.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -938,10 +938,10 @@ def handle_constants(type, var_name, const_name, definition)
938938
# "/* definition: comment */" form. The literal ':' and '\' characters
939939
# can be escaped with a backslash.
940940
if type.downcase == 'const' then
941-
no_match, new_definition, new_comment = comment.text.split(/(\A.*):/)
941+
if /\A(.+?)?:(?!\S)/ =~ comment.text
942+
new_definition, new_comment = $1, $'
942943

943-
if no_match and no_match.empty? then
944-
if new_definition.empty? then # Default to literal C definition
944+
if !new_definition # Default to literal C definition
945945
new_definition = definition
946946
else
947947
new_definition = new_definition.gsub(/\\([\\:])/, '\1')

test/rdoc/test_rdoc_parser_c.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ def test_do_constants
475475
/* TEST\:TEST: Checking to see if escaped colon works */
476476
rb_define_const(cFoo, "TEST", rb_str_new2("TEST:TEST"));
477477
478+
/* TEST: TEST:Checking to see if only word-ending colon works */
479+
rb_define_const(cFoo, "TEST2", rb_str_new2("TEST:TEST"));
480+
478481
/* \\: The file separator on MS Windows */
479482
rb_define_const(cFoo, "MSEPARATOR", rb_str_new2("\\"));
480483
@@ -538,6 +541,9 @@ def test_do_constants
538541
assert_equal ['TEST', 'TEST:TEST',
539542
'Checking to see if escaped colon works '],
540543
constants.shift
544+
assert_equal ['TEST2', 'TEST',
545+
'TEST:Checking to see if only word-ending colon works '],
546+
constants.shift
541547
assert_equal ['MSEPARATOR', '\\',
542548
'The file separator on MS Windows '],
543549
constants.shift

0 commit comments

Comments
 (0)