##// END OF EJS Templates
Ruby 1.9 compatibility of unified_diff.rb....
Toshi MARUYAMA -
r4777:7a9136f93ac5
parent child
Show More
@@ -22,12 +22,20 module Redmine
22 22 options.assert_valid_keys(:type, :max_lines)
23 23 diff = diff.split("\n") if diff.is_a?(String)
24 24 diff_type = options[:type] || 'inline'
25
26 25 lines = 0
27 26 @truncated = false
28 27 diff_table = DiffTable.new(diff_type)
29 28 diff.each do |line|
29 line_encoding = nil
30 if line.respond_to?(:force_encoding)
31 line_encoding = line.encoding
32 # TODO: UTF-16 and Japanese CP932 which is imcompatible with ASCII
33 # In Japan, diffrence between file path encoding
34 # and file contents encoding is popular.
35 line.force_encoding('ASCII-8BIT')
36 end
30 37 unless diff_table.add_line line
38 line.force_encoding(line_encoding) if line_encoding
31 39 self << diff_table if diff_table.length > 1
32 40 diff_table = DiffTable.new(diff_type)
33 41 end
@@ -40,7 +48,7 module Redmine
40 48 self << diff_table unless diff_table.empty?
41 49 self
42 50 end
43
51
44 52 def truncated?; @truncated; end
45 53 end
46 54
General Comments 0
You need to be logged in to leave comments. Login now