46cbe54189
directly force_encoding is wrong, must detect the file string's encoding. then force_encoding the string to it's encoding. last convert it to utf-8.
22 lines
558 B
Plaintext
22 lines
558 B
Plaintext
- line_old = 0
|
|
- line_new = 0
|
|
- lines_arr = diff.diff.lines.to_a
|
|
- lines_arr.each do |line|
|
|
- encode(line)
|
|
- next if line.match(/^--- \/dev\/null/)
|
|
- next if line.match(/^--- a/)
|
|
- next if line.match(/^\+\+\+ b/)
|
|
- if line.match(/^@@ -/)
|
|
- line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0
|
|
- line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0
|
|
- next
|
|
|
|
= diff_line(line, line_new, line_old)
|
|
- if line[0] == "+"
|
|
- line_new += 1
|
|
- elsif line[0] == "-"
|
|
- line_old += 1
|
|
- else
|
|
- line_new += 1
|
|
- line_old += 1
|