From 8db7c837f9bf69ca0264190f36e78cd5d6b12f84 Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 24 Dec 2007 16:44:39 +0000 Subject: [PATCH] * lib/rdoc/rdoc.rb (parse_files): interpret coding cookie. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ lib/rdoc/rdoc.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6b1eeed566..45fa1f4897 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Tue Dec 25 01:42:41 2007 Tanaka Akira + + * lib/rdoc/rdoc.rb (parse_files): interpret coding cookie. + Tue Dec 25 01:38:04 2007 Yukihiro Matsumoto * proc.c (method_name): preserve Symbol's encoding. diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb index af4a822da1..51038a1652 100644 --- a/lib/rdoc/rdoc.rb +++ b/lib/rdoc/rdoc.rb @@ -220,6 +220,11 @@ module RDoc $stderr.printf("\n%35s: ", File.basename(fn)) unless options.quiet content = File.open(fn, "r") {|f| f.read} + if /coding:\s*(\S+)/ =~ content[/\A(?:.*\n){0,2}/] + if enc = Encoding.find($1) + content.force_encoding(enc) + end + end top_level = TopLevel.new(fn) parser = ParserFactory.parser_for(top_level, fn, content, options, @stats)