diff --git a/History.rdoc b/History.rdoc index c4503f322a..6e34ba06af 100644 --- a/History.rdoc +++ b/History.rdoc @@ -6,6 +6,8 @@ * Fixed lexing of character syntax (?x). Reported by Xavier Noria. * Fixed tokenization of % when it is not followed by a $-string type + * Fixed display of __END__ in documentation examples in HTML output + === 3.12.1 / 2013-02-05 diff --git a/lib/rdoc/ruby_lex.rb b/lib/rdoc/ruby_lex.rb index e91cf46c10..f3cb0046a0 100644 --- a/lib/rdoc/ruby_lex.rb +++ b/lib/rdoc/ruby_lex.rb @@ -412,7 +412,7 @@ def token def lex_init() @OP = IRB::SLex.new @OP.def_rules("\0", "\004", "\032") do |op, io| - Token(TkEND_OF_SCRIPT) + Token(TkEND_OF_SCRIPT, '') end @OP.def_rules(" ", "\t", "\f", "\r", "\13") do |op, io| @@ -808,7 +808,8 @@ def lex_int2 @OP.def_rule("_") do if peek_match?(/_END__/) and @lex_state == EXPR_BEG then - Token(TkEND_OF_SCRIPT) + 6.times { getc } + Token(TkEND_OF_SCRIPT, '__END__') else ungetc identify_identifier diff --git a/test/test_rdoc_ruby_lex.rb b/test/test_rdoc_ruby_lex.rb index 08662a945c..4029c1472a 100644 --- a/test/test_rdoc_ruby_lex.rb +++ b/test/test_rdoc_ruby_lex.rb @@ -30,6 +30,17 @@ def test_class_tokenize assert_equal expected, tokens end + def test_class_tokenize___END__ + tokens = RDoc::RubyLex.tokenize '__END__', nil + + expected = [ + @TK::TkEND_OF_SCRIPT.new(0, 1, 0, '__END__'), + @TK::TkNL .new(7, 1, 7, "\n"), + ] + + assert_equal expected, tokens + end + def test_class_tokenize_character_literal tokens = RDoc::RubyLex.tokenize "?\\", nil