Skip to content

Commit

Permalink
Merge pull request #1342 from kmuto/io-rt
Browse files Browse the repository at this point in the history
File.open時に「rt」フラグで改行コードをLFに統一する
  • Loading branch information
kmuto authored Jul 5, 2019
2 parents 31a6a78 + 08088bd commit 6707fc5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lib/review/book/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def catalog

catalogfile_path = filename_join(@basedir, config['catalogfile'])
if File.file? catalogfile_path
@catalog = File.open(catalogfile_path, 'r:BOM|utf-8') { |f| Catalog.new(f) }
@catalog = File.open(catalogfile_path, 'rt:BOM|utf-8') { |f| Catalog.new(f) }
end
if @catalog
@catalog.validate!(@config, basedir)
Expand Down Expand Up @@ -352,7 +352,7 @@ def parse_chapters

def mkpart_from_namelistfile(path)
chaps = []
File.read(path, mode: 'r:BOM|utf-8').split.each_with_index do |name, idx|
File.read(path, mode: 'rt:BOM|utf-8').split.each_with_index do |name, idx|
if path =~ /PREDEF/
chaps << mkchap(name)
else
Expand Down Expand Up @@ -394,7 +394,7 @@ def read_file(filename)
end
end
res = ''
File.open(filename_join(@basedir, filename), 'r:BOM|utf-8') do |f|
File.open(filename_join(@basedir, filename), 'rt:BOM|utf-8') do |f|
f.each_line do |line|
next if /\A#/ =~ line
line.gsub!(/#.*\Z/, '')
Expand Down
4 changes: 2 additions & 2 deletions lib/review/book/chapter.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2009-2017 Minero Aoki, Kenshi Muto
# Copyright (c) 2009-2019 Minero Aoki, Kenshi Muto
# 2002-2008 Minero Aoki
#
# This program is free software.
Expand Down Expand Up @@ -35,7 +35,7 @@ def initialize(book, number, name, path, io = nil)
@content = nil
end
if !@content && @path && File.exist?(@path)
@content = File.read(@path, mode: 'r:BOM|utf-8')
@content = File.read(@path, mode: 'rt:BOM|utf-8')
@number = nil if %w[nonum nodisp notoc].include?(find_first_header_option)
end
@list_index = nil
Expand Down
4 changes: 2 additions & 2 deletions lib/review/book/part.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2009-2018 Minero Aoki, Kenshi Muto
# Copyright (c) 2009-2019 Minero Aoki, Kenshi Muto
# 2002-2008 Minero Aoki
#
# This program is free software.
Expand All @@ -25,7 +25,7 @@ def initialize(book, number, chapters, name = '', io = nil)
if io
@content = io.read
elsif @path.present? && File.exist?(File.join(@book.config['contentdir'], @path))
@content = File.read(File.join(@book.config['contentdir'], @path), mode: 'r:BOM|utf-8')
@content = File.read(File.join(@book.config['contentdir'], @path), mode: 'rt:BOM|utf-8')
@name = File.basename(@name, '.re')
end
if file?
Expand Down
2 changes: 1 addition & 1 deletion lib/review/preprocessor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def parse_git_blob(g_obj)
end

def parse_file(fname)
File.open(fname, 'r:BOM|utf-8') do |f|
File.open(fname, 'rt:BOM|utf-8') do |f|
init_errorutils f
return _parse_file(f)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/review/tocparser.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2008-2017 Minero Aoki, Kenshi Muto
# Copyright (c) 2008-2019 Minero Aoki, Kenshi Muto
# 2002-2007 Minero Aoki
#
# This program is free software.
Expand All @@ -15,7 +15,7 @@
module ReVIEW
class TOCParser
def self.parse(chap)
stream = StringIO.new(chap.content, 'r:BOM|utf-8')
stream = StringIO.new(chap.content, 'rt:BOM|utf-8')
new.parse(stream, chap).map do |root|
root.number = chap.number
root
Expand Down

0 comments on commit 6707fc5

Please sign in to comment.