diff-lcs 1.5.1 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +506 -0
- data/CODE_OF_CONDUCT.md +128 -0
- data/CONTRIBUTING.md +71 -0
- data/CONTRIBUTORS.md +48 -0
- data/{License.md → LICENCE.md} +15 -16
- data/Manifest.txt +61 -5
- data/README.md +92 -0
- data/Rakefile +19 -50
- data/SECURITY.md +41 -0
- data/docs/artistic.txt +1 -1
- data/lib/diff/lcs/change.rb +1 -1
- data/lib/diff/lcs/htmldiff.rb +2 -0
- data/lib/diff/lcs/hunk.rb +38 -22
- data/lib/diff/lcs/ldiff.rb +65 -49
- data/lib/diff/lcs/version.rb +7 -0
- data/lib/diff/lcs.rb +10 -9
- data/mise.toml +5 -0
- data/spec/fixtures/123_x +2 -0
- data/spec/fixtures/456_x +2 -0
- data/spec/fixtures/empty +0 -0
- data/spec/fixtures/file1.bin +0 -0
- data/spec/fixtures/file2.bin +0 -0
- data/spec/fixtures/four_lines +4 -0
- data/spec/fixtures/four_lines_with_missing_new_line +4 -0
- data/spec/fixtures/ldiff/diff.missing_new_line1-e +1 -0
- data/spec/fixtures/ldiff/diff.missing_new_line1-f +1 -0
- data/spec/fixtures/ldiff/diff.missing_new_line2-e +1 -0
- data/spec/fixtures/ldiff/diff.missing_new_line2-f +1 -0
- data/spec/fixtures/ldiff/error.diff.chef-e +2 -0
- data/spec/fixtures/ldiff/error.diff.chef-f +2 -0
- data/spec/fixtures/ldiff/error.diff.missing_new_line1-e +1 -0
- data/spec/fixtures/ldiff/error.diff.missing_new_line1-f +1 -0
- data/spec/fixtures/ldiff/error.diff.missing_new_line2-e +1 -0
- data/spec/fixtures/ldiff/error.diff.missing_new_line2-f +1 -0
- data/spec/fixtures/ldiff/output.diff.bin1 +0 -0
- data/spec/fixtures/ldiff/output.diff.bin1-c +0 -0
- data/spec/fixtures/ldiff/output.diff.bin1-e +0 -0
- data/spec/fixtures/ldiff/output.diff.bin1-f +0 -0
- data/spec/fixtures/ldiff/output.diff.bin1-u +0 -0
- data/spec/fixtures/ldiff/output.diff.bin2 +1 -0
- data/spec/fixtures/ldiff/output.diff.bin2-c +1 -0
- data/spec/fixtures/ldiff/output.diff.bin2-e +1 -0
- data/spec/fixtures/ldiff/output.diff.bin2-f +1 -0
- data/spec/fixtures/ldiff/output.diff.bin2-u +1 -0
- data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines +5 -0
- data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines-c +9 -0
- data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines-e +6 -0
- data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines-f +6 -0
- data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines-u +7 -0
- data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty +5 -0
- data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty-c +9 -0
- data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty-e +1 -0
- data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty-f +1 -0
- data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty-u +7 -0
- data/spec/fixtures/ldiff/output.diff.issue95_trailing_context +4 -0
- data/spec/fixtures/ldiff/output.diff.issue95_trailing_context-c +9 -0
- data/spec/fixtures/ldiff/output.diff.issue95_trailing_context-e +3 -0
- data/spec/fixtures/ldiff/output.diff.issue95_trailing_context-f +3 -0
- data/spec/fixtures/ldiff/output.diff.issue95_trailing_context-u +6 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line1 +5 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line1-c +14 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line1-e +0 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line1-f +0 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line1-u +9 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line2 +5 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line2-c +14 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line2-e +0 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line2-f +0 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line2-u +9 -0
- data/spec/hunk_spec.rb +1 -1
- data/spec/issues_spec.rb +32 -32
- data/spec/ldiff_spec.rb +21 -10
- data/spec/patch_spec.rb +1 -1
- data/spec/spec_helper.rb +93 -93
- metadata +86 -64
- data/Code-of-Conduct.md +0 -74
- data/Contributing.md +0 -121
- data/History.md +0 -431
- data/README.rdoc +0 -84
data/lib/diff/lcs/hunk.rb
CHANGED
@@ -22,11 +22,13 @@ class Diff::LCS::Hunk
|
|
22
22
|
end
|
23
23
|
|
24
24
|
if String.method_defined?(:encoding)
|
25
|
-
@preferred_data_encoding = data_old.fetch(0) { data_new.fetch(0
|
25
|
+
@preferred_data_encoding = data_old.fetch(0) { data_new.fetch(0) { "" } }.encoding
|
26
26
|
end
|
27
27
|
|
28
28
|
@data_old = data_old
|
29
29
|
@data_new = data_new
|
30
|
+
@old_empty = data_old.empty? || (data_old.size == 1 && data_old[0].empty?)
|
31
|
+
@new_empty = data_new.empty? || (data_new.size == 1 && data_new[0].empty?)
|
30
32
|
|
31
33
|
before = after = file_length_difference
|
32
34
|
after += @blocks[0].diff_size
|
@@ -79,14 +81,12 @@ class Diff::LCS::Hunk
|
|
79
81
|
old_size = @data_old.size
|
80
82
|
|
81
83
|
add_end =
|
82
|
-
if (@end_old + context)
|
83
|
-
old_size - @end_old
|
84
|
+
if (@end_old + context) >= old_size
|
85
|
+
old_size - @end_old - 1
|
84
86
|
else
|
85
87
|
context
|
86
88
|
end
|
87
89
|
|
88
|
-
add_end = @max_diff_size if add_end >= old_size
|
89
|
-
|
90
90
|
@end_old += add_end
|
91
91
|
@end_new += add_end
|
92
92
|
end
|
@@ -131,11 +131,16 @@ class Diff::LCS::Hunk
|
|
131
131
|
|
132
132
|
# Note that an old diff can't have any context. Therefore, we know that
|
133
133
|
# there's only one block in the hunk.
|
134
|
-
def old_diff(
|
134
|
+
def old_diff(last = false)
|
135
135
|
warn "Expecting only one block in an old diff hunk!" if @blocks.size > 1
|
136
136
|
|
137
137
|
block = @blocks[0]
|
138
138
|
|
139
|
+
if last
|
140
|
+
old_missing_newline = !@old_empty && missing_last_newline?(@data_old)
|
141
|
+
new_missing_newline = !@new_empty && missing_last_newline?(@data_new)
|
142
|
+
end
|
143
|
+
|
139
144
|
# Calculate item number range. Old diff range is just like a context
|
140
145
|
# diff range, except the ranges are on one line with the action between
|
141
146
|
# them.
|
@@ -146,19 +151,22 @@ class Diff::LCS::Hunk
|
|
146
151
|
@data_old[@start_old..@end_old].each { |e| s << encode("< ") + e.chomp + encode("\n") }
|
147
152
|
end
|
148
153
|
|
154
|
+
s << encode("\\n") if old_missing_newline && !new_missing_newline
|
149
155
|
s << encode("---\n") if block.op == "!"
|
150
156
|
|
151
157
|
unless block.insert.empty?
|
152
158
|
@data_new[@start_new..@end_new].each { |e| s << encode("> ") + e.chomp + encode("\n") }
|
153
159
|
end
|
154
160
|
|
161
|
+
s << encode("\\n") if new_missing_newline && !old_missing_newline
|
162
|
+
|
155
163
|
s
|
156
164
|
end
|
157
165
|
private :old_diff
|
158
166
|
|
159
167
|
def unified_diff(last = false)
|
160
168
|
# Calculate item number range.
|
161
|
-
s = encode("@@ -#{unified_range(:old
|
169
|
+
s = encode("@@ -#{unified_range(:old)} +#{unified_range(:new)} @@\n")
|
162
170
|
|
163
171
|
# Outlist starts containing the hunk of the old file. Removing an item
|
164
172
|
# just means putting a '-' in front of it. Inserting an item requires
|
@@ -178,8 +186,8 @@ class Diff::LCS::Hunk
|
|
178
186
|
last_block = blocks[-1]
|
179
187
|
|
180
188
|
if last
|
181
|
-
old_missing_newline = missing_last_newline?(@data_old)
|
182
|
-
new_missing_newline = missing_last_newline?(@data_new)
|
189
|
+
old_missing_newline = !@old_empty && missing_last_newline?(@data_old)
|
190
|
+
new_missing_newline = !@new_empty && missing_last_newline?(@data_new)
|
183
191
|
end
|
184
192
|
|
185
193
|
@blocks.each do |block|
|
@@ -213,8 +221,8 @@ class Diff::LCS::Hunk
|
|
213
221
|
|
214
222
|
def context_diff(last = false)
|
215
223
|
s = encode("***************\n")
|
216
|
-
s << encode("*** #{context_range(:old, ","
|
217
|
-
r = context_range(:new, ","
|
224
|
+
s << encode("*** #{context_range(:old, ",")} ****\n")
|
225
|
+
r = context_range(:new, ",")
|
218
226
|
|
219
227
|
if last
|
220
228
|
old_missing_newline = missing_last_newline?(@data_old)
|
@@ -273,14 +281,24 @@ class Diff::LCS::Hunk
|
|
273
281
|
end
|
274
282
|
private :context_diff
|
275
283
|
|
276
|
-
def ed_diff(format,
|
284
|
+
def ed_diff(format, last)
|
277
285
|
warn "Expecting only one block in an old diff hunk!" if @blocks.size > 1
|
286
|
+
if last
|
287
|
+
# ed script doesn't support well incomplete lines
|
288
|
+
warn "<old_file>: No newline at end of file\n" if !@old_empty && missing_last_newline?(@data_old)
|
289
|
+
warn "<new_file>: No newline at end of file\n" if !@new_empty && missing_last_newline?(@data_new)
|
290
|
+
|
291
|
+
if @blocks[0].op == "!"
|
292
|
+
return +"" if @blocks[0].changes[0].element == @blocks[0].changes[1].element + "\n"
|
293
|
+
return +"" if @blocks[0].changes[0].element + "\n" == @blocks[0].changes[1].element
|
294
|
+
end
|
295
|
+
end
|
278
296
|
|
279
297
|
s =
|
280
298
|
if format == :reverse_ed
|
281
|
-
encode("#{ED_DIFF_OP_ACTION[@blocks[0].op]}#{context_range(:old, "
|
299
|
+
encode("#{ED_DIFF_OP_ACTION[@blocks[0].op]}#{context_range(:old, " ")}\n")
|
282
300
|
else
|
283
|
-
encode("#{context_range(:old, "
|
301
|
+
encode("#{context_range(:old, ",")}#{ED_DIFF_OP_ACTION[@blocks[0].op]}\n")
|
284
302
|
end
|
285
303
|
|
286
304
|
unless @blocks[0].insert.empty?
|
@@ -295,7 +313,7 @@ class Diff::LCS::Hunk
|
|
295
313
|
|
296
314
|
# Generate a range of item numbers to print. Only print 1 number if the
|
297
315
|
# range has only one item in it. Otherwise, it's 'start,end'
|
298
|
-
def context_range(mode, op
|
316
|
+
def context_range(mode, op)
|
299
317
|
case mode
|
300
318
|
when :old
|
301
319
|
s, e = (@start_old + 1), (@end_old + 1)
|
@@ -303,9 +321,6 @@ class Diff::LCS::Hunk
|
|
303
321
|
s, e = (@start_new + 1), (@end_new + 1)
|
304
322
|
end
|
305
323
|
|
306
|
-
e -= 1 if last
|
307
|
-
e = 1 if e.zero?
|
308
|
-
|
309
324
|
(s < e) ? "#{s}#{op}#{e}" : e.to_s
|
310
325
|
end
|
311
326
|
private :context_range
|
@@ -313,18 +328,19 @@ class Diff::LCS::Hunk
|
|
313
328
|
# Generate a range of item numbers to print for unified diff. Print number
|
314
329
|
# where block starts, followed by number of lines in the block
|
315
330
|
# (don't print number of lines if it's 1)
|
316
|
-
def unified_range(mode
|
331
|
+
def unified_range(mode)
|
317
332
|
case mode
|
318
333
|
when :old
|
334
|
+
return "0,0" if @old_empty
|
319
335
|
s, e = (@start_old + 1), (@end_old + 1)
|
320
336
|
when :new
|
337
|
+
return "0,0" if @new_empty
|
321
338
|
s, e = (@start_new + 1), (@end_new + 1)
|
322
339
|
end
|
323
340
|
|
324
|
-
length = e - s +
|
341
|
+
length = e - s + 1
|
325
342
|
|
326
|
-
|
327
|
-
(length <= 1) ? first.to_s : "#{first},#{length}"
|
343
|
+
(length <= 1) ? e.to_s : "#{s},#{length}"
|
328
344
|
end
|
329
345
|
private :unified_range
|
330
346
|
|
data/lib/diff/lcs/ldiff.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "optparse"
|
4
|
-
require "ostruct"
|
5
4
|
require "diff/lcs/hunk"
|
6
5
|
|
7
|
-
|
6
|
+
class Diff::LCS::Ldiff # :nodoc:
|
8
7
|
# standard:disable Layout/HeredocIndentation
|
9
8
|
BANNER = <<-COPYRIGHT
|
10
9
|
ldiff #{Diff::LCS::VERSION}
|
11
|
-
Copyright 2004-
|
10
|
+
Copyright 2004-2025 Austin Ziegler
|
12
11
|
|
13
12
|
Part of Diff::LCS.
|
14
13
|
https://github.com/halostatue/diff-lcs
|
@@ -18,16 +17,28 @@ ldiff #{Diff::LCS::VERSION}
|
|
18
17
|
MIT licence.
|
19
18
|
COPYRIGHT
|
20
19
|
# standard:enable Layout/HeredocIndentation
|
21
|
-
end
|
22
20
|
|
23
|
-
|
21
|
+
InputInfo = Struct.new(:filename, :data, :stat) do
|
22
|
+
def initialize(filename)
|
23
|
+
super(filename, ::File.read(filename), ::File.stat(filename))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
24
27
|
attr_reader :format, :lines # :nodoc:
|
25
28
|
attr_reader :file_old, :file_new # :nodoc:
|
26
29
|
attr_reader :data_old, :data_new # :nodoc:
|
27
30
|
|
28
|
-
def run(args,
|
31
|
+
def self.run(args, input = $stdin, output = $stdout, error = $stderr) # :nodoc:
|
32
|
+
new.run(args, input, output, error)
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize
|
29
36
|
@binary = nil
|
37
|
+
@format = :old
|
38
|
+
@lines = 0
|
39
|
+
end
|
30
40
|
|
41
|
+
def run(args, _input = $stdin, output = $stdout, error = $stderr) # :nodoc:
|
31
42
|
args.options do |o|
|
32
43
|
o.banner = "Usage: #{File.basename($0)} [options] oldfile newfile"
|
33
44
|
o.separator ""
|
@@ -86,8 +97,18 @@ class << Diff::LCS::Ldiff
|
|
86
97
|
@lines ||= 0
|
87
98
|
|
88
99
|
file_old, file_new = *ARGV
|
100
|
+
diff?(
|
101
|
+
InputInfo.new(file_old),
|
102
|
+
InputInfo.new(file_new),
|
103
|
+
@format,
|
104
|
+
output,
|
105
|
+
binary: @binary,
|
106
|
+
lines: @lines
|
107
|
+
) ? 1 : 0
|
108
|
+
end
|
89
109
|
|
90
|
-
|
110
|
+
def diff?(info_old, info_new, format, output, binary: nil, lines: 0)
|
111
|
+
case format
|
91
112
|
when :context
|
92
113
|
char_old = "*" * 3
|
93
114
|
char_new = "-" * 3
|
@@ -100,74 +121,69 @@ class << Diff::LCS::Ldiff
|
|
100
121
|
# items we've read from each file will differ by FLD (could be 0).
|
101
122
|
file_length_difference = 0
|
102
123
|
|
103
|
-
data_old = File.read(file_old)
|
104
|
-
data_new = File.read(file_new)
|
105
|
-
|
106
124
|
# Test binary status
|
107
|
-
if
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
unless @binary
|
114
|
-
data_old = data_old.lines.to_a
|
115
|
-
data_new = data_new.lines.to_a
|
125
|
+
if binary.nil?
|
126
|
+
old_bin = info_old.data[0, 4096].include?("\0")
|
127
|
+
new_bin = info_new.data[0, 4096].include?("\0")
|
128
|
+
binary = old_bin || new_bin
|
116
129
|
end
|
117
130
|
|
118
131
|
# diff yields lots of pieces, each of which is basically a Block object
|
119
|
-
if
|
120
|
-
|
132
|
+
if binary
|
133
|
+
has_diffs = (info_old.data != info_new.data)
|
134
|
+
if format != :report
|
135
|
+
if has_diffs
|
136
|
+
output << "Binary files #{info_old.filename} and #{info_new.filename} differ\n"
|
137
|
+
return true
|
138
|
+
end
|
139
|
+
return false
|
140
|
+
end
|
121
141
|
else
|
142
|
+
data_old = info_old.data.lines.to_a
|
143
|
+
data_new = info_new.data.lines.to_a
|
122
144
|
diffs = Diff::LCS.diff(data_old, data_new)
|
123
|
-
|
124
|
-
end
|
125
|
-
|
126
|
-
return 0 unless diffs
|
127
|
-
|
128
|
-
if @format == :report
|
129
|
-
output << "Files #{file_old} and #{file_new} differ\n"
|
130
|
-
return 1
|
145
|
+
return false if diffs.empty?
|
131
146
|
end
|
132
147
|
|
133
|
-
|
134
|
-
|
135
|
-
output << "#{
|
136
|
-
|
137
|
-
|
148
|
+
case format
|
149
|
+
when :report
|
150
|
+
output << "Files #{info_old.filename} and #{info_new.filename} differ\n"
|
151
|
+
return true
|
152
|
+
when :unified, :context
|
153
|
+
ft = info_old.stat.mtime.localtime.strftime("%Y-%m-%d %H:%M:%S.000000000 %z")
|
154
|
+
output << "#{char_old} #{info_old.filename}\t#{ft}\n"
|
155
|
+
ft = info_new.stat.mtime.localtime.strftime("%Y-%m-%d %H:%M:%S.000000000 %z")
|
156
|
+
output << "#{char_new} #{info_new.filename}\t#{ft}\n"
|
157
|
+
when :ed
|
158
|
+
real_output = output
|
159
|
+
output = []
|
138
160
|
end
|
139
161
|
|
140
162
|
# Loop over hunks. If a hunk overlaps with the last hunk, join them.
|
141
163
|
# Otherwise, print out the old one.
|
142
164
|
oldhunk = hunk = nil
|
143
|
-
|
144
|
-
if @format == :ed
|
145
|
-
real_output = output
|
146
|
-
output = []
|
147
|
-
end
|
148
|
-
|
149
165
|
diffs.each do |piece|
|
150
|
-
begin
|
151
|
-
hunk = Diff::LCS::Hunk.new(data_old, data_new, piece,
|
166
|
+
begin
|
167
|
+
hunk = Diff::LCS::Hunk.new(data_old, data_new, piece, lines, file_length_difference)
|
152
168
|
file_length_difference = hunk.file_length_difference
|
153
169
|
|
154
170
|
next unless oldhunk
|
155
|
-
next if
|
171
|
+
next if lines.positive? && hunk.merge(oldhunk)
|
156
172
|
|
157
|
-
output << oldhunk.diff(
|
158
|
-
output << "\n" if
|
173
|
+
output << oldhunk.diff(format)
|
174
|
+
output << "\n" if format == :unified
|
159
175
|
ensure
|
160
176
|
oldhunk = hunk
|
161
177
|
end
|
162
178
|
end
|
163
179
|
|
164
|
-
last = oldhunk.diff(
|
165
|
-
last << "\n"
|
180
|
+
last = oldhunk.diff(format, true)
|
181
|
+
last << "\n" unless last.is_a?(Diff::LCS::Hunk) || last.empty? || last.end_with?("\n")
|
166
182
|
|
167
183
|
output << last
|
168
184
|
|
169
|
-
output.reverse_each { |e| real_output << e.diff(:ed_finish) } if
|
185
|
+
output.reverse_each { |e| real_output << e.diff(:ed_finish, e == output[0]) } if format == :ed
|
170
186
|
|
171
|
-
|
187
|
+
true
|
172
188
|
end
|
173
189
|
end
|
data/lib/diff/lcs.rb
CHANGED
@@ -49,9 +49,9 @@ module Diff; end unless defined? Diff
|
|
49
49
|
# a x b y c z p d q
|
50
50
|
# a b c a x b y c z
|
51
51
|
module Diff::LCS
|
52
|
-
VERSION = "1.5.1"
|
53
52
|
end
|
54
53
|
|
54
|
+
require "diff/lcs/version"
|
55
55
|
require "diff/lcs/callbacks"
|
56
56
|
require "diff/lcs/internals"
|
57
57
|
|
@@ -62,11 +62,12 @@ module Diff::LCS
|
|
62
62
|
# lcs = seq1.lcs(seq2)
|
63
63
|
#
|
64
64
|
# A note when using objects: Diff::LCS only works properly when each object
|
65
|
-
# can be used as a key in a Hash
|
66
|
-
#
|
67
|
-
# identically for key purposes. That is:
|
65
|
+
# can be used as a key in a Hash. This means that those objects must implement
|
66
|
+
# the methods +#hash+ and +#eql?+ such that two objects containing identical values
|
67
|
+
# compare identically for key purposes. That is:
|
68
68
|
#
|
69
|
-
# O.new('a').eql?(O.new('a')) == true
|
69
|
+
# O.new('a').eql?(O.new('a')) == true &&
|
70
|
+
# O.new('a').hash == O.new('a').hash
|
70
71
|
def lcs(other, &block) # :yields: self[i] if there are matched subsequences
|
71
72
|
Diff::LCS.lcs(self, other, &block)
|
72
73
|
end
|
@@ -256,7 +257,7 @@ class << Diff::LCS
|
|
256
257
|
#
|
257
258
|
# The methods for <tt>callbacks#match</tt>, <tt>callbacks#discard_a</tt>, and
|
258
259
|
# <tt>callbacks#discard_b</tt> are invoked with an event comprising the
|
259
|
-
# action ("=", "+", or "-", respectively), the
|
260
|
+
# action ("=", "+", or "-", respectively), the indexes +i+ and +j+, and the
|
260
261
|
# elements <tt>A[i]</tt> and <tt>B[j]</tt>. Return values are discarded by
|
261
262
|
# #traverse_sequences.
|
262
263
|
#
|
@@ -421,7 +422,7 @@ class << Diff::LCS
|
|
421
422
|
# occurred.
|
422
423
|
#
|
423
424
|
# #traverse_balanced might be a bit slower than #traverse_sequences,
|
424
|
-
#
|
425
|
+
# noticeable only while processing huge amounts of data.
|
425
426
|
#
|
426
427
|
# == Algorithm
|
427
428
|
#
|
@@ -465,7 +466,7 @@ class << Diff::LCS
|
|
465
466
|
# The methods for <tt>callbacks#match</tt>, <tt>callbacks#discard_a</tt>,
|
466
467
|
# <tt>callbacks#discard_b</tt>, and <tt>callbacks#change</tt> are invoked
|
467
468
|
# with an event comprising the action ("=", "+", "-", or "!", respectively),
|
468
|
-
# the
|
469
|
+
# the indexes +i+ and +j+, and the elements <tt>A[i]</tt> and <tt>B[j]</tt>.
|
469
470
|
# Return values are discarded by #traverse_balanced.
|
470
471
|
#
|
471
472
|
# === Context
|
@@ -482,7 +483,7 @@ class << Diff::LCS
|
|
482
483
|
|
483
484
|
# Process all the lines in the match vector.
|
484
485
|
loop do
|
485
|
-
# Find next match
|
486
|
+
# Find next match indexes +ma+ and +mb+
|
486
487
|
loop do
|
487
488
|
ma += 1
|
488
489
|
break unless ma < matches.size && matches[ma].nil?
|
data/mise.toml
ADDED
data/spec/fixtures/123_x
ADDED
data/spec/fixtures/456_x
ADDED
data/spec/fixtures/empty
ADDED
File without changes
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
No newline at end of file
|
@@ -0,0 +1 @@
|
|
1
|
+
No newline at end of file
|
@@ -0,0 +1 @@
|
|
1
|
+
No newline at end of file
|
@@ -0,0 +1 @@
|
|
1
|
+
No newline at end of file
|
@@ -0,0 +1 @@
|
|
1
|
+
<new_file>: No newline at end of file
|
@@ -0,0 +1 @@
|
|
1
|
+
<new_file>: No newline at end of file
|
@@ -0,0 +1 @@
|
|
1
|
+
<old_file>: No newline at end of file
|
@@ -0,0 +1 @@
|
|
1
|
+
<old_file>: No newline at end of file
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
|
@@ -0,0 +1 @@
|
|
1
|
+
Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
|
@@ -0,0 +1 @@
|
|
1
|
+
Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
|
@@ -0,0 +1 @@
|
|
1
|
+
Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
|
@@ -0,0 +1 @@
|
|
1
|
+
Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
|
@@ -0,0 +1 @@
|
|
1
|
+
1,4d
|
@@ -0,0 +1 @@
|
|
1
|
+
d1 4
|
@@ -0,0 +1,14 @@
|
|
1
|
+
*** spec/fixtures/four_lines 2025-01-31 12:17:43.926013315 +0100
|
2
|
+
--- spec/fixtures/four_lines_with_missing_new_line 2025-01-31 12:17:43.926013315 +0100
|
3
|
+
***************
|
4
|
+
*** 1,4 ****
|
5
|
+
one
|
6
|
+
two
|
7
|
+
three
|
8
|
+
! four
|
9
|
+
--- 1,4 ----
|
10
|
+
one
|
11
|
+
two
|
12
|
+
three
|
13
|
+
! four
|
14
|
+
|
File without changes
|
File without changes
|