Project

General

Profile

Actions

Bug #3360

closed

rdoc fails when including BOM

Added by whiteleaf (whiteleaf _) almost 14 years ago. Updated about 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3dev (2010-05-28 trunk 28052) [i386-cygwin]
Backport:
[ruby-dev:41452]

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 @@
-
+"?>

Index: rdoc.rb =================================================================== --- rdoc.rb (リビジョン 28052) +++ rdoc.rb (作業コピー) @@ -404,12 +404,17 @@ end
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
     end
    

    end
    =end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0