summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAustin Ziegler <austin@surfeasy.com>2013-01-20 21:46:38 -0500
committerAustin Ziegler <austin@surfeasy.com>2013-01-20 21:46:38 -0500
commit42eef5d7050e1daf258533a4adcb0ceedea68b28 (patch)
treed8931417ca2ae8c3fe9d466ca2331f393d2b6de2 /lib
parent98703123469f68e25768fac0decef79534a59d01 (diff)
downloaddiff-lcs-42eef5d7050e1daf258533a4adcb0ceedea68b28.tar.gz
Fixing issues with ldiff output.
The output is now indistinguishable from diff (at least for -u).
Diffstat (limited to 'lib')
-rw-r--r--lib/diff/lcs/ldiff.rb22
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/diff/lcs/ldiff.rb b/lib/diff/lcs/ldiff.rb
index 93d1e4a..1da3875 100644
--- a/lib/diff/lcs/ldiff.rb
+++ b/lib/diff/lcs/ldiff.rb
@@ -123,19 +123,19 @@ class << Diff::LCS::Ldiff
# Test binary status
if @binary.nil?
- old_txt = data_old[0...4096].grep(/\0/).empty?
- new_txt = data_new[0...4096].grep(/\0/).empty?
+ old_txt = data_old[0...4096].scan(/\0/).empty?
+ new_txt = data_new[0...4096].scan(/\0/).empty?
@binary = (not old_txt) or (not new_txt)
old_txt = new_txt = nil
end
unless @binary
- data_old = data_old.split(/\n/).map! { |e| e.chomp }
- data_new = data_new.split(/\n/).map! { |e| e.chomp }
+ data_old = data_old.split($/).map { |e| e.chomp }
+ data_new = data_new.split($/).map { |e| e.chomp }
end
else
- data_old = IO::readlines(file_old).map! { |e| e.chomp }
- data_new = IO::readlines(file_new).map! { |e| e.chomp }
+ data_old = IO::readlines(file_old).map { |e| e.chomp }
+ data_new = IO::readlines(file_new).map { |e| e.chomp }
end
# diff yields lots of pieces, each of which is basically a Block object
@@ -154,9 +154,9 @@ class << Diff::LCS::Ldiff
end
if (@format == :unified) or (@format == :context)
- ft = File.stat(file_old).mtime.localtime.strftime('%Y-%m-%d %H:%M:%S %z')
+ ft = File.stat(file_old).mtime.localtime.strftime('%Y-%m-%d %H:%M:%S.%N %z')
puts "#{char_old} #{file_old}\t#{ft}"
- ft = File.stat(file_new).mtime.localtime.strftime('%Y-%m-%d %H:%M:%S %z')
+ ft = File.stat(file_new).mtime.localtime.strftime('%Y-%m-%d %H:%M:%S.%N %z')
puts "#{char_new} #{file_new}\t#{ft}"
end
@@ -178,15 +178,13 @@ class << Diff::LCS::Ldiff
next unless oldhunk
next if (@lines > 0) and hunk.merge(oldhunk)
- output << oldhunk.diff(@format)
+ output << oldhunk.diff(@format) << "\n"
ensure
oldhunk = hunk
- output << "\n"
end
end
- output << oldhunk.diff(@format)
- output << "\n"
+ output << oldhunk.diff(@format) << "\n"
if @format == :ed
output.reverse_each { |e| real_output << e.diff(:ed_finish) }