Bug #3360
closedrdoc fails when including BOM
Description
=begin
whiteleaf と申します。
BOM を含むファイルを rdoc にかけると処理が固まります。
rdoc が BOM を見てないせいなので、以下のパッチでなおりました。
・":bom|utf-8" オプションを使っていないのは 1.8 のためと
結局 ASCII-8BIT に force_encoding しないといけないため意味がないからです。
(rdoc のエンコーディングを UTF-8 にするなら別ですが)
・UTF-8 の BOM しか見ていないのは ruby スクリプトに使わない(使えない)
ので意味がないからです。
・encode してるのは複数のファイルが異なるエンコーディングを使っている場合に
charset とエンコーディングが異なる可能性があるためです。
余談ですが、bom|utf-* オプションはエンコーディングが未知の場合には¶
ほとんど意味が無いなあと思いました。¶
Index: generator/template/darkfish/classpage.rhtml¶
--- generator/template/darkfish/classpage.rhtml (リビジョン 28052)
+++ generator/template/darkfish/classpage.rhtml (作業コピー)
@@ -1,4 +1,4 @@
-
+"?>
def read_file_contents(filename)
-
utf8_bom = [0xEF, 0xBB, 0xBF].pack("C*")
content = open filename, "rb" do |f| f.read end -
if content[0..2] == utf8_bom then
-
content = content[3..-1] -
end
if defined? Encoding then
if /coding[=:]\s*([^\s;]+)/i =~ content[%r"\A(?:#!.\n)?.\n"]
if enc = ::Encoding.find($1)
content.force_encoding(enc) -
content.encode!(@options.charset) end endend
=end