diff-lcs 1.5.0 → 1.5.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/Contributing.md +2 -0
 - data/History.md +86 -55
 - data/License.md +6 -4
 - data/Rakefile +36 -27
 - data/bin/htmldiff +4 -4
 - data/lib/diff/lcs/array.rb +1 -1
 - data/lib/diff/lcs/backports.rb +2 -2
 - data/lib/diff/lcs/block.rb +4 -4
 - data/lib/diff/lcs/callbacks.rb +9 -7
 - data/lib/diff/lcs/change.rb +19 -19
 - data/lib/diff/lcs/htmldiff.rb +24 -16
 - data/lib/diff/lcs/hunk.rb +35 -30
 - data/lib/diff/lcs/internals.rb +17 -17
 - data/lib/diff/lcs/ldiff.rb +37 -35
 - data/lib/diff/lcs.rb +57 -55
 - data/lib/diff-lcs.rb +1 -1
 - data/spec/change_spec.rb +50 -50
 - data/spec/diff_spec.rb +14 -14
 - data/spec/hunk_spec.rb +19 -19
 - data/spec/issues_spec.rb +48 -42
 - data/spec/lcs_spec.rb +11 -11
 - data/spec/ldiff_spec.rb +13 -11
 - data/spec/patch_spec.rb +84 -84
 - data/spec/sdiff_spec.rb +111 -109
 - data/spec/spec_helper.rb +76 -74
 - data/spec/traverse_balanced_spec.rb +191 -189
 - data/spec/traverse_sequences_spec.rb +31 -31
 - metadata +28 -21
 
    
        data/lib/diff/lcs/ldiff.rb
    CHANGED
    
    | 
         @@ -1,10 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            require  
     | 
| 
       4 
     | 
    
         
            -
            require  
     | 
| 
       5 
     | 
    
         
            -
            require  
     | 
| 
      
 3 
     | 
    
         
            +
            require "optparse"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "ostruct"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "diff/lcs/hunk"
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
            module Diff::LCS::Ldiff  
     | 
| 
      
 7 
     | 
    
         
            +
            module Diff::LCS::Ldiff # :nodoc:
         
     | 
| 
      
 8 
     | 
    
         
            +
              # standard:disable Layout/HeredocIndentation
         
     | 
| 
       8 
9 
     | 
    
         
             
              BANNER = <<-COPYRIGHT
         
     | 
| 
       9 
10 
     | 
    
         
             
            ldiff #{Diff::LCS::VERSION}
         
     | 
| 
       10 
11 
     | 
    
         
             
              Copyright 2004-2019 Austin Ziegler
         
     | 
| 
         @@ -16,60 +17,61 @@ ldiff #{Diff::LCS::VERSION} 
     | 
|
| 
       16 
17 
     | 
    
         
             
              the terms of the GPL version 2 (or later), the Perl Artistic licence, or the
         
     | 
| 
       17 
18 
     | 
    
         
             
              MIT licence.
         
     | 
| 
       18 
19 
     | 
    
         
             
              COPYRIGHT
         
     | 
| 
      
 20 
     | 
    
         
            +
              # standard:enable Layout/HeredocIndentation
         
     | 
| 
       19 
21 
     | 
    
         
             
            end
         
     | 
| 
       20 
22 
     | 
    
         | 
| 
       21 
23 
     | 
    
         
             
            class << Diff::LCS::Ldiff
         
     | 
| 
       22 
     | 
    
         
            -
              attr_reader :format, :lines  
     | 
| 
       23 
     | 
    
         
            -
              attr_reader :file_old, :file_new  
     | 
| 
       24 
     | 
    
         
            -
              attr_reader :data_old, :data_new  
     | 
| 
      
 24 
     | 
    
         
            +
              attr_reader :format, :lines # :nodoc:
         
     | 
| 
      
 25 
     | 
    
         
            +
              attr_reader :file_old, :file_new # :nodoc:
         
     | 
| 
      
 26 
     | 
    
         
            +
              attr_reader :data_old, :data_new # :nodoc:
         
     | 
| 
       25 
27 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
              def run(args, _input = $stdin, output = $stdout, error = $stderr)  
     | 
| 
      
 28 
     | 
    
         
            +
              def run(args, _input = $stdin, output = $stdout, error = $stderr) # :nodoc:
         
     | 
| 
       27 
29 
     | 
    
         
             
                @binary = nil
         
     | 
| 
       28 
30 
     | 
    
         | 
| 
       29 
31 
     | 
    
         
             
                args.options do |o|
         
     | 
| 
       30 
32 
     | 
    
         
             
                  o.banner = "Usage: #{File.basename($0)} [options] oldfile newfile"
         
     | 
| 
       31 
     | 
    
         
            -
                  o.separator  
     | 
| 
      
 33 
     | 
    
         
            +
                  o.separator ""
         
     | 
| 
       32 
34 
     | 
    
         
             
                  o.on(
         
     | 
| 
       33 
     | 
    
         
            -
                     
     | 
| 
       34 
     | 
    
         
            -
                     
     | 
| 
      
 35 
     | 
    
         
            +
                    "-c", "-C", "--context [LINES]", Integer,
         
     | 
| 
      
 36 
     | 
    
         
            +
                    "Displays a context diff with LINES lines", "of context. Default 3 lines."
         
     | 
| 
       35 
37 
     | 
    
         
             
                  ) do |ctx|
         
     | 
| 
       36 
38 
     | 
    
         
             
                    @format = :context
         
     | 
| 
       37 
     | 
    
         
            -
                    @lines 
     | 
| 
      
 39 
     | 
    
         
            +
                    @lines = ctx || 3
         
     | 
| 
       38 
40 
     | 
    
         
             
                  end
         
     | 
| 
       39 
41 
     | 
    
         
             
                  o.on(
         
     | 
| 
       40 
     | 
    
         
            -
                     
     | 
| 
       41 
     | 
    
         
            -
                     
     | 
| 
      
 42 
     | 
    
         
            +
                    "-u", "-U", "--unified [LINES]", Integer,
         
     | 
| 
      
 43 
     | 
    
         
            +
                    "Displays a unified diff with LINES lines", "of context. Default 3 lines."
         
     | 
| 
       42 
44 
     | 
    
         
             
                  ) do |ctx|
         
     | 
| 
       43 
45 
     | 
    
         
             
                    @format = :unified
         
     | 
| 
       44 
     | 
    
         
            -
                    @lines 
     | 
| 
      
 46 
     | 
    
         
            +
                    @lines = ctx || 3
         
     | 
| 
       45 
47 
     | 
    
         
             
                  end
         
     | 
| 
       46 
     | 
    
         
            -
                  o.on( 
     | 
| 
      
 48 
     | 
    
         
            +
                  o.on("-e", "Creates an 'ed' script to change", "oldfile to newfile.") do |_ctx|
         
     | 
| 
       47 
49 
     | 
    
         
             
                    @format = :ed
         
     | 
| 
       48 
50 
     | 
    
         
             
                  end
         
     | 
| 
       49 
     | 
    
         
            -
                  o.on( 
     | 
| 
      
 51 
     | 
    
         
            +
                  o.on("-f", "Creates an 'ed' script to change", "oldfile to newfile in reverse order.") do |_ctx|
         
     | 
| 
       50 
52 
     | 
    
         
             
                    @format = :reverse_ed
         
     | 
| 
       51 
53 
     | 
    
         
             
                  end
         
     | 
| 
       52 
54 
     | 
    
         
             
                  o.on(
         
     | 
| 
       53 
     | 
    
         
            -
                     
     | 
| 
       54 
     | 
    
         
            -
                     
     | 
| 
      
 55 
     | 
    
         
            +
                    "-a", "--text",
         
     | 
| 
      
 56 
     | 
    
         
            +
                    "Treat the files as text and compare them", "line-by-line, even if they do not seem", "to be text."
         
     | 
| 
       55 
57 
     | 
    
         
             
                  ) do |_txt|
         
     | 
| 
       56 
58 
     | 
    
         
             
                    @binary = false
         
     | 
| 
       57 
59 
     | 
    
         
             
                  end
         
     | 
| 
       58 
     | 
    
         
            -
                  o.on( 
     | 
| 
      
 60 
     | 
    
         
            +
                  o.on("--binary", "Treats the files as binary.") do |_bin|
         
     | 
| 
       59 
61 
     | 
    
         
             
                    @binary = true
         
     | 
| 
       60 
62 
     | 
    
         
             
                  end
         
     | 
| 
       61 
     | 
    
         
            -
                  o.on( 
     | 
| 
      
 63 
     | 
    
         
            +
                  o.on("-q", "--brief", "Report only whether or not the files", "differ, not the details.") do |_ctx|
         
     | 
| 
       62 
64 
     | 
    
         
             
                    @format = :report
         
     | 
| 
       63 
65 
     | 
    
         
             
                  end
         
     | 
| 
       64 
     | 
    
         
            -
                  o.on_tail( 
     | 
| 
      
 66 
     | 
    
         
            +
                  o.on_tail("--help", "Shows this text.") do
         
     | 
| 
       65 
67 
     | 
    
         
             
                    error << o
         
     | 
| 
       66 
68 
     | 
    
         
             
                    return 0
         
     | 
| 
       67 
69 
     | 
    
         
             
                  end
         
     | 
| 
       68 
     | 
    
         
            -
                  o.on_tail( 
     | 
| 
      
 70 
     | 
    
         
            +
                  o.on_tail("--version", "Shows the version of Diff::LCS.") do
         
     | 
| 
       69 
71 
     | 
    
         
             
                    error << Diff::LCS::Ldiff::BANNER
         
     | 
| 
       70 
72 
     | 
    
         
             
                    return 0
         
     | 
| 
       71 
73 
     | 
    
         
             
                  end
         
     | 
| 
       72 
     | 
    
         
            -
                  o.on_tail  
     | 
| 
      
 74 
     | 
    
         
            +
                  o.on_tail ""
         
     | 
| 
       73 
75 
     | 
    
         
             
                  o.on_tail 'By default, runs produces an "old-style" diff, with output like UNIX diff.'
         
     | 
| 
       74 
76 
     | 
    
         
             
                  o.parse!
         
     | 
| 
       75 
77 
     | 
    
         
             
                end
         
     | 
| 
         @@ -81,25 +83,25 @@ class << Diff::LCS::Ldiff 
     | 
|
| 
       81 
83 
     | 
    
         | 
| 
       82 
84 
     | 
    
         
             
                # Defaults are for old-style diff
         
     | 
| 
       83 
85 
     | 
    
         
             
                @format ||= :old
         
     | 
| 
       84 
     | 
    
         
            -
                @lines 
     | 
| 
      
 86 
     | 
    
         
            +
                @lines ||= 0
         
     | 
| 
       85 
87 
     | 
    
         | 
| 
       86 
88 
     | 
    
         
             
                file_old, file_new = *ARGV
         
     | 
| 
       87 
89 
     | 
    
         | 
| 
       88 
90 
     | 
    
         
             
                case @format
         
     | 
| 
       89 
91 
     | 
    
         
             
                when :context
         
     | 
| 
       90 
     | 
    
         
            -
                  char_old =  
     | 
| 
       91 
     | 
    
         
            -
                  char_new =  
     | 
| 
      
 92 
     | 
    
         
            +
                  char_old = "*" * 3
         
     | 
| 
      
 93 
     | 
    
         
            +
                  char_new = "-" * 3
         
     | 
| 
       92 
94 
     | 
    
         
             
                when :unified
         
     | 
| 
       93 
     | 
    
         
            -
                  char_old =  
     | 
| 
       94 
     | 
    
         
            -
                  char_new =  
     | 
| 
      
 95 
     | 
    
         
            +
                  char_old = "-" * 3
         
     | 
| 
      
 96 
     | 
    
         
            +
                  char_new = "+" * 3
         
     | 
| 
       95 
97 
     | 
    
         
             
                end
         
     | 
| 
       96 
98 
     | 
    
         | 
| 
       97 
99 
     | 
    
         
             
                # After we've read up to a certain point in each file, the number of
         
     | 
| 
       98 
100 
     | 
    
         
             
                # items we've read from each file will differ by FLD (could be 0).
         
     | 
| 
       99 
101 
     | 
    
         
             
                file_length_difference = 0
         
     | 
| 
       100 
102 
     | 
    
         | 
| 
       101 
     | 
    
         
            -
                data_old =  
     | 
| 
       102 
     | 
    
         
            -
                data_new =  
     | 
| 
      
 103 
     | 
    
         
            +
                data_old = File.read(file_old)
         
     | 
| 
      
 104 
     | 
    
         
            +
                data_new = File.read(file_new)
         
     | 
| 
       103 
105 
     | 
    
         | 
| 
       104 
106 
     | 
    
         
             
                # Test binary status
         
     | 
| 
       105 
107 
     | 
    
         
             
                if @binary.nil?
         
     | 
| 
         @@ -128,10 +130,10 @@ class << Diff::LCS::Ldiff 
     | 
|
| 
       128 
130 
     | 
    
         
             
                  return 1
         
     | 
| 
       129 
131 
     | 
    
         
             
                end
         
     | 
| 
       130 
132 
     | 
    
         | 
| 
       131 
     | 
    
         
            -
                if (@format == :unified)  
     | 
| 
       132 
     | 
    
         
            -
                  ft = File.stat(file_old).mtime.localtime.strftime( 
     | 
| 
      
 133 
     | 
    
         
            +
                if (@format == :unified) || (@format == :context)
         
     | 
| 
      
 134 
     | 
    
         
            +
                  ft = File.stat(file_old).mtime.localtime.strftime("%Y-%m-%d %H:%M:%S.000000000 %z")
         
     | 
| 
       133 
135 
     | 
    
         
             
                  output << "#{char_old} #{file_old}\t#{ft}\n"
         
     | 
| 
       134 
     | 
    
         
            -
                  ft = File.stat(file_new).mtime.localtime.strftime( 
     | 
| 
      
 136 
     | 
    
         
            +
                  ft = File.stat(file_new).mtime.localtime.strftime("%Y-%m-%d %H:%M:%S.000000000 %z")
         
     | 
| 
       135 
137 
     | 
    
         
             
                  output << "#{char_new} #{file_new}\t#{ft}\n"
         
     | 
| 
       136 
138 
     | 
    
         
             
                end
         
     | 
| 
       137 
139 
     | 
    
         | 
| 
         @@ -150,7 +152,7 @@ class << Diff::LCS::Ldiff 
     | 
|
| 
       150 
152 
     | 
    
         
             
                    file_length_difference = hunk.file_length_difference
         
     | 
| 
       151 
153 
     | 
    
         | 
| 
       152 
154 
     | 
    
         
             
                    next unless oldhunk
         
     | 
| 
       153 
     | 
    
         
            -
                    next if @lines.positive?  
     | 
| 
      
 155 
     | 
    
         
            +
                    next if @lines.positive? && hunk.merge(oldhunk)
         
     | 
| 
       154 
156 
     | 
    
         | 
| 
       155 
157 
     | 
    
         
             
                    output << oldhunk.diff(@format)
         
     | 
| 
       156 
158 
     | 
    
         
             
                    output << "\n" if @format == :unified
         
     | 
    
        data/lib/diff/lcs.rb
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            module Diff; end unless defined? Diff 
     | 
| 
      
 3 
     | 
    
         
            +
            module Diff; end unless defined? Diff
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            # == How Diff Works (by Mark-Jason Dominus)
         
     | 
| 
       6 
6 
     | 
    
         
             
            #
         
     | 
| 
         @@ -49,13 +49,13 @@ module Diff; end unless defined? Diff # rubocop:disable Style/Documentation 
     | 
|
| 
       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 =  
     | 
| 
      
 52 
     | 
    
         
            +
              VERSION = "1.5.1"
         
     | 
| 
       53 
53 
     | 
    
         
             
            end
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
            require  
     | 
| 
       56 
     | 
    
         
            -
            require  
     | 
| 
      
 55 
     | 
    
         
            +
            require "diff/lcs/callbacks"
         
     | 
| 
      
 56 
     | 
    
         
            +
            require "diff/lcs/internals"
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
     | 
    
         
            -
            module Diff::LCS 
     | 
| 
      
 58 
     | 
    
         
            +
            module Diff::LCS
         
     | 
| 
       59 
59 
     | 
    
         
             
              # Returns an Array containing the longest common subsequence(s) between
         
     | 
| 
       60 
60 
     | 
    
         
             
              # +self+ and +other+. See Diff::LCS#lcs.
         
     | 
| 
       61 
61 
     | 
    
         
             
              #
         
     | 
| 
         @@ -67,7 +67,7 @@ module Diff::LCS # rubocop:disable Style/Documentation 
     | 
|
| 
       67 
67 
     | 
    
         
             
              # identically for key purposes. That is:
         
     | 
| 
       68 
68 
     | 
    
         
             
              #
         
     | 
| 
       69 
69 
     | 
    
         
             
              #   O.new('a').eql?(O.new('a')) == true
         
     | 
| 
       70 
     | 
    
         
            -
              def lcs(other, &block)  
     | 
| 
      
 70 
     | 
    
         
            +
              def lcs(other, &block) # :yields: self[i] if there are matched subsequences
         
     | 
| 
       71 
71 
     | 
    
         
             
                Diff::LCS.lcs(self, other, &block)
         
     | 
| 
       72 
72 
     | 
    
         
             
              end
         
     | 
| 
       73 
73 
     | 
    
         | 
| 
         @@ -101,7 +101,7 @@ module Diff::LCS # rubocop:disable Style/Documentation 
     | 
|
| 
       101 
101 
     | 
    
         
             
              def patch(patchset)
         
     | 
| 
       102 
102 
     | 
    
         
             
                Diff::LCS.patch(self, patchset)
         
     | 
| 
       103 
103 
     | 
    
         
             
              end
         
     | 
| 
       104 
     | 
    
         
            -
               
     | 
| 
      
 104 
     | 
    
         
            +
              alias_method :unpatch, :patch
         
     | 
| 
       105 
105 
     | 
    
         | 
| 
       106 
106 
     | 
    
         
             
              # Attempts to patch +self+ with the provided +patchset+. A new sequence based
         
     | 
| 
       107 
107 
     | 
    
         
             
              # on +self+ and the +patchset+ will be created. See Diff::LCS#patch. Does no
         
     | 
| 
         @@ -141,11 +141,11 @@ module Diff::LCS # rubocop:disable Style/Documentation 
     | 
|
| 
       141 
141 
     | 
    
         
             
            end
         
     | 
| 
       142 
142 
     | 
    
         | 
| 
       143 
143 
     | 
    
         
             
            class << Diff::LCS
         
     | 
| 
       144 
     | 
    
         
            -
              def lcs(seq1, seq2, &block)  
     | 
| 
      
 144 
     | 
    
         
            +
              def lcs(seq1, seq2, &block) # :yields: seq1[i] for each matched
         
     | 
| 
       145 
145 
     | 
    
         
             
                matches = Diff::LCS::Internals.lcs(seq1, seq2)
         
     | 
| 
       146 
146 
     | 
    
         
             
                ret = []
         
     | 
| 
       147 
     | 
    
         
            -
                string = seq1. 
     | 
| 
       148 
     | 
    
         
            -
                matches. 
     | 
| 
      
 147 
     | 
    
         
            +
                string = seq1.is_a? String
         
     | 
| 
      
 148 
     | 
    
         
            +
                matches.each_index do |i|
         
     | 
| 
       149 
149 
     | 
    
         
             
                  next if matches[i].nil?
         
     | 
| 
       150 
150 
     | 
    
         | 
| 
       151 
151 
     | 
    
         
             
                  v = string ? seq1[i, 1] : seq1[i]
         
     | 
| 
         @@ -154,7 +154,7 @@ class << Diff::LCS 
     | 
|
| 
       154 
154 
     | 
    
         
             
                end
         
     | 
| 
       155 
155 
     | 
    
         
             
                ret
         
     | 
| 
       156 
156 
     | 
    
         
             
              end
         
     | 
| 
       157 
     | 
    
         
            -
               
     | 
| 
      
 157 
     | 
    
         
            +
              alias_method :LCS, :lcs
         
     | 
| 
       158 
158 
     | 
    
         | 
| 
       159 
159 
     | 
    
         
             
              # #diff computes the smallest set of additions and deletions necessary to
         
     | 
| 
       160 
160 
     | 
    
         
             
              # turn the first sequence into the second, and returns a description of these
         
     | 
| 
         @@ -165,7 +165,7 @@ class << Diff::LCS 
     | 
|
| 
       165 
165 
     | 
    
         
             
              # Class argument is provided for +callbacks+, #diff will attempt to
         
     | 
| 
       166 
166 
     | 
    
         
             
              # initialise it. If the +callbacks+ object (possibly initialised) responds to
         
     | 
| 
       167 
167 
     | 
    
         
             
              # #finish, it will be called.
         
     | 
| 
       168 
     | 
    
         
            -
              def diff(seq1, seq2, callbacks = nil, &block) # :yields diff changes 
     | 
| 
      
 168 
     | 
    
         
            +
              def diff(seq1, seq2, callbacks = nil, &block) # :yields: diff changes
         
     | 
| 
       169 
169 
     | 
    
         
             
                diff_traversal(:diff, seq1, seq2, callbacks || Diff::LCS::DiffCallbacks, &block)
         
     | 
| 
       170 
170 
     | 
    
         
             
              end
         
     | 
| 
       171 
171 
     | 
    
         | 
| 
         @@ -197,7 +197,7 @@ class << Diff::LCS 
     | 
|
| 
       197 
197 
     | 
    
         
             
              #       # insert
         
     | 
| 
       198 
198 
     | 
    
         
             
              #     end
         
     | 
| 
       199 
199 
     | 
    
         
             
              #   end
         
     | 
| 
       200 
     | 
    
         
            -
              def sdiff(seq1, seq2, callbacks = nil, &block)  
     | 
| 
      
 200 
     | 
    
         
            +
              def sdiff(seq1, seq2, callbacks = nil, &block) # :yields: diff changes
         
     | 
| 
       201 
201 
     | 
    
         
             
                diff_traversal(:sdiff, seq1, seq2, callbacks || Diff::LCS::SDiffCallbacks, &block)
         
     | 
| 
       202 
202 
     | 
    
         
             
              end
         
     | 
| 
       203 
203 
     | 
    
         | 
| 
         @@ -282,12 +282,12 @@ class << Diff::LCS 
     | 
|
| 
       282 
282 
     | 
    
         
             
              # <tt>callbacks#discard_b</tt> will be called after the end of the sequence
         
     | 
| 
       283 
283 
     | 
    
         
             
              # is reached, if +a+ has not yet reached the end of +A+ or +b+ has not yet
         
     | 
| 
       284 
284 
     | 
    
         
             
              # reached the end of +B+.
         
     | 
| 
       285 
     | 
    
         
            -
              def traverse_sequences(seq1, seq2, callbacks = Diff::LCS::SequenceCallbacks)  
     | 
| 
      
 285 
     | 
    
         
            +
              def traverse_sequences(seq1, seq2, callbacks = Diff::LCS::SequenceCallbacks) # :yields: change events
         
     | 
| 
       286 
286 
     | 
    
         
             
                callbacks ||= Diff::LCS::SequenceCallbacks
         
     | 
| 
       287 
287 
     | 
    
         
             
                matches = Diff::LCS::Internals.lcs(seq1, seq2)
         
     | 
| 
       288 
288 
     | 
    
         | 
| 
       289 
289 
     | 
    
         
             
                run_finished_a = run_finished_b = false
         
     | 
| 
       290 
     | 
    
         
            -
                string = seq1. 
     | 
| 
      
 290 
     | 
    
         
            +
                string = seq1.is_a?(String)
         
     | 
| 
       291 
291 
     | 
    
         | 
| 
       292 
292 
     | 
    
         
             
                a_size = seq1.size
         
     | 
| 
       293 
293 
     | 
    
         
             
                b_size = seq2.size
         
     | 
| 
         @@ -299,7 +299,7 @@ class << Diff::LCS 
     | 
|
| 
       299 
299 
     | 
    
         
             
                      ax = string ? seq1[ai, 1] : seq1[ai]
         
     | 
| 
       300 
300 
     | 
    
         
             
                      bx = string ? seq2[bj, 1] : seq2[bj]
         
     | 
| 
       301 
301 
     | 
    
         | 
| 
       302 
     | 
    
         
            -
                      event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 302 
     | 
    
         
            +
                      event = Diff::LCS::ContextChange.new("-", ai, ax, bj, bx)
         
     | 
| 
       303 
303 
     | 
    
         
             
                      event = yield event if block_given?
         
     | 
| 
       304 
304 
     | 
    
         
             
                      callbacks.discard_a(event)
         
     | 
| 
       305 
305 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -310,13 +310,13 @@ class << Diff::LCS 
     | 
|
| 
       310 
310 
     | 
    
         
             
                      break unless bj < b_line
         
     | 
| 
       311 
311 
     | 
    
         | 
| 
       312 
312 
     | 
    
         
             
                      bx = string ? seq2[bj, 1] : seq2[bj]
         
     | 
| 
       313 
     | 
    
         
            -
                      event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 313 
     | 
    
         
            +
                      event = Diff::LCS::ContextChange.new("+", ai, ax, bj, bx)
         
     | 
| 
       314 
314 
     | 
    
         
             
                      event = yield event if block_given?
         
     | 
| 
       315 
315 
     | 
    
         
             
                      callbacks.discard_b(event)
         
     | 
| 
       316 
316 
     | 
    
         
             
                      bj += 1
         
     | 
| 
       317 
317 
     | 
    
         
             
                    end
         
     | 
| 
       318 
318 
     | 
    
         
             
                    bx = string ? seq2[bj, 1] : seq2[bj]
         
     | 
| 
       319 
     | 
    
         
            -
                    event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 319 
     | 
    
         
            +
                    event = Diff::LCS::ContextChange.new("=", ai, ax, bj, bx)
         
     | 
| 
       320 
320 
     | 
    
         
             
                    event = yield event if block_given?
         
     | 
| 
       321 
321 
     | 
    
         
             
                    callbacks.match(event)
         
     | 
| 
       322 
322 
     | 
    
         
             
                    bj += 1
         
     | 
| 
         @@ -326,13 +326,13 @@ class << Diff::LCS 
     | 
|
| 
       326 
326 
     | 
    
         | 
| 
       327 
327 
     | 
    
         
             
                # The last entry (if any) processed was a match. +ai+ and +bj+ point just
         
     | 
| 
       328 
328 
     | 
    
         
             
                # past the last matching lines in their sequences.
         
     | 
| 
       329 
     | 
    
         
            -
                while (ai < a_size)  
     | 
| 
      
 329 
     | 
    
         
            +
                while (ai < a_size) || (bj < b_size)
         
     | 
| 
       330 
330 
     | 
    
         
             
                  # last A?
         
     | 
| 
       331 
     | 
    
         
            -
                  if ai == a_size  
     | 
| 
       332 
     | 
    
         
            -
                    if callbacks.respond_to?(:finished_a)  
     | 
| 
      
 331 
     | 
    
         
            +
                  if ai == a_size && bj < b_size
         
     | 
| 
      
 332 
     | 
    
         
            +
                    if callbacks.respond_to?(:finished_a) && !run_finished_a
         
     | 
| 
       333 
333 
     | 
    
         
             
                      ax = string ? seq1[-1, 1] : seq1[-1]
         
     | 
| 
       334 
334 
     | 
    
         
             
                      bx = string ? seq2[bj, 1] : seq2[bj]
         
     | 
| 
       335 
     | 
    
         
            -
                      event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 335 
     | 
    
         
            +
                      event = Diff::LCS::ContextChange.new(">", (a_size - 1), ax, bj, bx)
         
     | 
| 
       336 
336 
     | 
    
         
             
                      event = yield event if block_given?
         
     | 
| 
       337 
337 
     | 
    
         
             
                      callbacks.finished_a(event)
         
     | 
| 
       338 
338 
     | 
    
         
             
                      run_finished_a = true
         
     | 
| 
         @@ -340,7 +340,7 @@ class << Diff::LCS 
     | 
|
| 
       340 
340 
     | 
    
         
             
                      ax = string ? seq1[ai, 1] : seq1[ai]
         
     | 
| 
       341 
341 
     | 
    
         
             
                      loop do
         
     | 
| 
       342 
342 
     | 
    
         
             
                        bx = string ? seq2[bj, 1] : seq2[bj]
         
     | 
| 
       343 
     | 
    
         
            -
                        event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 343 
     | 
    
         
            +
                        event = Diff::LCS::ContextChange.new("+", ai, ax, bj, bx)
         
     | 
| 
       344 
344 
     | 
    
         
             
                        event = yield event if block_given?
         
     | 
| 
       345 
345 
     | 
    
         
             
                        callbacks.discard_b(event)
         
     | 
| 
       346 
346 
     | 
    
         
             
                        bj += 1
         
     | 
| 
         @@ -350,11 +350,11 @@ class << Diff::LCS 
     | 
|
| 
       350 
350 
     | 
    
         
             
                  end
         
     | 
| 
       351 
351 
     | 
    
         | 
| 
       352 
352 
     | 
    
         
             
                  # last B?
         
     | 
| 
       353 
     | 
    
         
            -
                  if bj == b_size  
     | 
| 
       354 
     | 
    
         
            -
                    if callbacks.respond_to?(:finished_b)  
     | 
| 
      
 353 
     | 
    
         
            +
                  if bj == b_size && ai < a_size
         
     | 
| 
      
 354 
     | 
    
         
            +
                    if callbacks.respond_to?(:finished_b) && !run_finished_b
         
     | 
| 
       355 
355 
     | 
    
         
             
                      ax = string ? seq1[ai, 1] : seq1[ai]
         
     | 
| 
       356 
356 
     | 
    
         
             
                      bx = string ? seq2[-1, 1] : seq2[-1]
         
     | 
| 
       357 
     | 
    
         
            -
                      event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 357 
     | 
    
         
            +
                      event = Diff::LCS::ContextChange.new("<", ai, ax, (b_size - 1), bx)
         
     | 
| 
       358 
358 
     | 
    
         
             
                      event = yield event if block_given?
         
     | 
| 
       359 
359 
     | 
    
         
             
                      callbacks.finished_b(event)
         
     | 
| 
       360 
360 
     | 
    
         
             
                      run_finished_b = true
         
     | 
| 
         @@ -362,7 +362,7 @@ class << Diff::LCS 
     | 
|
| 
       362 
362 
     | 
    
         
             
                      bx = string ? seq2[bj, 1] : seq2[bj]
         
     | 
| 
       363 
363 
     | 
    
         
             
                      loop do
         
     | 
| 
       364 
364 
     | 
    
         
             
                        ax = string ? seq1[ai, 1] : seq1[ai]
         
     | 
| 
       365 
     | 
    
         
            -
                        event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 365 
     | 
    
         
            +
                        event = Diff::LCS::ContextChange.new("-", ai, ax, bj, bx)
         
     | 
| 
       366 
366 
     | 
    
         
             
                        event = yield event if block_given?
         
     | 
| 
       367 
367 
     | 
    
         
             
                        callbacks.discard_a(event)
         
     | 
| 
       368 
368 
     | 
    
         
             
                        ai += 1
         
     | 
| 
         @@ -374,7 +374,7 @@ class << Diff::LCS 
     | 
|
| 
       374 
374 
     | 
    
         
             
                  if ai < a_size
         
     | 
| 
       375 
375 
     | 
    
         
             
                    ax = string ? seq1[ai, 1] : seq1[ai]
         
     | 
| 
       376 
376 
     | 
    
         
             
                    bx = string ? seq2[bj, 1] : seq2[bj]
         
     | 
| 
       377 
     | 
    
         
            -
                    event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 377 
     | 
    
         
            +
                    event = Diff::LCS::ContextChange.new("-", ai, ax, bj, bx)
         
     | 
| 
       378 
378 
     | 
    
         
             
                    event = yield event if block_given?
         
     | 
| 
       379 
379 
     | 
    
         
             
                    callbacks.discard_a(event)
         
     | 
| 
       380 
380 
     | 
    
         
             
                    ai += 1
         
     | 
| 
         @@ -383,7 +383,7 @@ class << Diff::LCS 
     | 
|
| 
       383 
383 
     | 
    
         
             
                  if bj < b_size
         
     | 
| 
       384 
384 
     | 
    
         
             
                    ax = string ? seq1[ai, 1] : seq1[ai]
         
     | 
| 
       385 
385 
     | 
    
         
             
                    bx = string ? seq2[bj, 1] : seq2[bj]
         
     | 
| 
       386 
     | 
    
         
            -
                    event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 386 
     | 
    
         
            +
                    event = Diff::LCS::ContextChange.new("+", ai, ax, bj, bx)
         
     | 
| 
       387 
387 
     | 
    
         
             
                    event = yield event if block_given?
         
     | 
| 
       388 
388 
     | 
    
         
             
                    callbacks.discard_b(event)
         
     | 
| 
       389 
389 
     | 
    
         
             
                    bj += 1
         
     | 
| 
         @@ -478,14 +478,14 @@ class << Diff::LCS 
     | 
|
| 
       478 
478 
     | 
    
         
             
                b_size = seq2.size
         
     | 
| 
       479 
479 
     | 
    
         
             
                ai = bj = mb = 0
         
     | 
| 
       480 
480 
     | 
    
         
             
                ma = -1
         
     | 
| 
       481 
     | 
    
         
            -
                string = seq1. 
     | 
| 
      
 481 
     | 
    
         
            +
                string = seq1.is_a?(String)
         
     | 
| 
       482 
482 
     | 
    
         | 
| 
       483 
483 
     | 
    
         
             
                # Process all the lines in the match vector.
         
     | 
| 
       484 
484 
     | 
    
         
             
                loop do
         
     | 
| 
       485 
485 
     | 
    
         
             
                  # Find next match indices +ma+ and +mb+
         
     | 
| 
       486 
486 
     | 
    
         
             
                  loop do
         
     | 
| 
       487 
487 
     | 
    
         
             
                    ma += 1
         
     | 
| 
       488 
     | 
    
         
            -
                    break unless ma < matches.size  
     | 
| 
      
 488 
     | 
    
         
            +
                    break unless ma < matches.size && matches[ma].nil?
         
     | 
| 
       489 
489 
     | 
    
         
             
                  end
         
     | 
| 
       490 
490 
     | 
    
         | 
| 
       491 
491 
     | 
    
         
             
                  break if ma >= matches.size # end of matches?
         
     | 
| 
         @@ -493,36 +493,36 @@ class << Diff::LCS 
     | 
|
| 
       493 
493 
     | 
    
         
             
                  mb = matches[ma]
         
     | 
| 
       494 
494 
     | 
    
         | 
| 
       495 
495 
     | 
    
         
             
                  # Change(seq2)
         
     | 
| 
       496 
     | 
    
         
            -
                  while (ai < ma)  
     | 
| 
      
 496 
     | 
    
         
            +
                  while (ai < ma) || (bj < mb)
         
     | 
| 
       497 
497 
     | 
    
         
             
                    ax = string ? seq1[ai, 1] : seq1[ai]
         
     | 
| 
       498 
498 
     | 
    
         
             
                    bx = string ? seq2[bj, 1] : seq2[bj]
         
     | 
| 
       499 
499 
     | 
    
         | 
| 
       500 
500 
     | 
    
         
             
                    case [(ai < ma), (bj < mb)]
         
     | 
| 
       501 
501 
     | 
    
         
             
                    when [true, true]
         
     | 
| 
       502 
502 
     | 
    
         
             
                      if callbacks.respond_to?(:change)
         
     | 
| 
       503 
     | 
    
         
            -
                        event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 503 
     | 
    
         
            +
                        event = Diff::LCS::ContextChange.new("!", ai, ax, bj, bx)
         
     | 
| 
       504 
504 
     | 
    
         
             
                        event = yield event if block_given?
         
     | 
| 
       505 
505 
     | 
    
         
             
                        callbacks.change(event)
         
     | 
| 
       506 
506 
     | 
    
         
             
                        ai += 1
         
     | 
| 
       507 
507 
     | 
    
         
             
                      else
         
     | 
| 
       508 
     | 
    
         
            -
                        event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 508 
     | 
    
         
            +
                        event = Diff::LCS::ContextChange.new("-", ai, ax, bj, bx)
         
     | 
| 
       509 
509 
     | 
    
         
             
                        event = yield event if block_given?
         
     | 
| 
       510 
510 
     | 
    
         
             
                        callbacks.discard_a(event)
         
     | 
| 
       511 
511 
     | 
    
         
             
                        ai += 1
         
     | 
| 
       512 
512 
     | 
    
         
             
                        ax = string ? seq1[ai, 1] : seq1[ai]
         
     | 
| 
       513 
     | 
    
         
            -
                        event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 513 
     | 
    
         
            +
                        event = Diff::LCS::ContextChange.new("+", ai, ax, bj, bx)
         
     | 
| 
       514 
514 
     | 
    
         
             
                        event = yield event if block_given?
         
     | 
| 
       515 
515 
     | 
    
         
             
                        callbacks.discard_b(event)
         
     | 
| 
       516 
516 
     | 
    
         
             
                      end
         
     | 
| 
       517 
517 
     | 
    
         | 
| 
       518 
518 
     | 
    
         
             
                      bj += 1
         
     | 
| 
       519 
519 
     | 
    
         
             
                    when [true, false]
         
     | 
| 
       520 
     | 
    
         
            -
                      event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 520 
     | 
    
         
            +
                      event = Diff::LCS::ContextChange.new("-", ai, ax, bj, bx)
         
     | 
| 
       521 
521 
     | 
    
         
             
                      event = yield event if block_given?
         
     | 
| 
       522 
522 
     | 
    
         
             
                      callbacks.discard_a(event)
         
     | 
| 
       523 
523 
     | 
    
         
             
                      ai += 1
         
     | 
| 
       524 
524 
     | 
    
         
             
                    when [false, true]
         
     | 
| 
       525 
     | 
    
         
            -
                      event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 525 
     | 
    
         
            +
                      event = Diff::LCS::ContextChange.new("+", ai, ax, bj, bx)
         
     | 
| 
       526 
526 
     | 
    
         
             
                      event = yield event if block_given?
         
     | 
| 
       527 
527 
     | 
    
         
             
                      callbacks.discard_b(event)
         
     | 
| 
       528 
528 
     | 
    
         
             
                      bj += 1
         
     | 
| 
         @@ -532,43 +532,43 @@ class << Diff::LCS 
     | 
|
| 
       532 
532 
     | 
    
         
             
                  # Match
         
     | 
| 
       533 
533 
     | 
    
         
             
                  ax = string ? seq1[ai, 1] : seq1[ai]
         
     | 
| 
       534 
534 
     | 
    
         
             
                  bx = string ? seq2[bj, 1] : seq2[bj]
         
     | 
| 
       535 
     | 
    
         
            -
                  event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 535 
     | 
    
         
            +
                  event = Diff::LCS::ContextChange.new("=", ai, ax, bj, bx)
         
     | 
| 
       536 
536 
     | 
    
         
             
                  event = yield event if block_given?
         
     | 
| 
       537 
537 
     | 
    
         
             
                  callbacks.match(event)
         
     | 
| 
       538 
538 
     | 
    
         
             
                  ai += 1
         
     | 
| 
       539 
539 
     | 
    
         
             
                  bj += 1
         
     | 
| 
       540 
540 
     | 
    
         
             
                end
         
     | 
| 
       541 
541 
     | 
    
         | 
| 
       542 
     | 
    
         
            -
                while (ai < a_size)  
     | 
| 
      
 542 
     | 
    
         
            +
                while (ai < a_size) || (bj < b_size)
         
     | 
| 
       543 
543 
     | 
    
         
             
                  ax = string ? seq1[ai, 1] : seq1[ai]
         
     | 
| 
       544 
544 
     | 
    
         
             
                  bx = string ? seq2[bj, 1] : seq2[bj]
         
     | 
| 
       545 
545 
     | 
    
         | 
| 
       546 
546 
     | 
    
         
             
                  case [(ai < a_size), (bj < b_size)]
         
     | 
| 
       547 
547 
     | 
    
         
             
                  when [true, true]
         
     | 
| 
       548 
548 
     | 
    
         
             
                    if callbacks.respond_to?(:change)
         
     | 
| 
       549 
     | 
    
         
            -
                      event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 549 
     | 
    
         
            +
                      event = Diff::LCS::ContextChange.new("!", ai, ax, bj, bx)
         
     | 
| 
       550 
550 
     | 
    
         
             
                      event = yield event if block_given?
         
     | 
| 
       551 
551 
     | 
    
         
             
                      callbacks.change(event)
         
     | 
| 
       552 
552 
     | 
    
         
             
                      ai += 1
         
     | 
| 
       553 
553 
     | 
    
         
             
                    else
         
     | 
| 
       554 
     | 
    
         
            -
                      event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 554 
     | 
    
         
            +
                      event = Diff::LCS::ContextChange.new("-", ai, ax, bj, bx)
         
     | 
| 
       555 
555 
     | 
    
         
             
                      event = yield event if block_given?
         
     | 
| 
       556 
556 
     | 
    
         
             
                      callbacks.discard_a(event)
         
     | 
| 
       557 
557 
     | 
    
         
             
                      ai += 1
         
     | 
| 
       558 
558 
     | 
    
         
             
                      ax = string ? seq1[ai, 1] : seq1[ai]
         
     | 
| 
       559 
     | 
    
         
            -
                      event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 559 
     | 
    
         
            +
                      event = Diff::LCS::ContextChange.new("+", ai, ax, bj, bx)
         
     | 
| 
       560 
560 
     | 
    
         
             
                      event = yield event if block_given?
         
     | 
| 
       561 
561 
     | 
    
         
             
                      callbacks.discard_b(event)
         
     | 
| 
       562 
562 
     | 
    
         
             
                    end
         
     | 
| 
       563 
563 
     | 
    
         | 
| 
       564 
564 
     | 
    
         
             
                    bj += 1
         
     | 
| 
       565 
565 
     | 
    
         
             
                  when [true, false]
         
     | 
| 
       566 
     | 
    
         
            -
                    event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 566 
     | 
    
         
            +
                    event = Diff::LCS::ContextChange.new("-", ai, ax, bj, bx)
         
     | 
| 
       567 
567 
     | 
    
         
             
                    event = yield event if block_given?
         
     | 
| 
       568 
568 
     | 
    
         
             
                    callbacks.discard_a(event)
         
     | 
| 
       569 
569 
     | 
    
         
             
                    ai += 1
         
     | 
| 
       570 
570 
     | 
    
         
             
                  when [false, true]
         
     | 
| 
       571 
     | 
    
         
            -
                    event = Diff::LCS::ContextChange.new( 
     | 
| 
      
 571 
     | 
    
         
            +
                    event = Diff::LCS::ContextChange.new("+", ai, ax, bj, bx)
         
     | 
| 
       572 
572 
     | 
    
         
             
                    event = yield event if block_given?
         
     | 
| 
       573 
573 
     | 
    
         
             
                    callbacks.discard_b(event)
         
     | 
| 
       574 
574 
     | 
    
         
             
                    bj += 1
         
     | 
| 
         @@ -576,10 +576,12 @@ class << Diff::LCS 
     | 
|
| 
       576 
576 
     | 
    
         
             
                end
         
     | 
| 
       577 
577 
     | 
    
         
             
              end
         
     | 
| 
       578 
578 
     | 
    
         | 
| 
       579 
     | 
    
         
            -
               
     | 
| 
       580 
     | 
    
         
            -
             
     | 
| 
       581 
     | 
    
         
            -
                : 
     | 
| 
      
 579 
     | 
    
         
            +
              # standard:disable Style/HashSyntax
         
     | 
| 
      
 580 
     | 
    
         
            +
              PATCH_MAP = { # :nodoc:
         
     | 
| 
      
 581 
     | 
    
         
            +
                :patch => {"+" => "+", "-" => "-", "!" => "!", "=" => "="}.freeze,
         
     | 
| 
      
 582 
     | 
    
         
            +
                :unpatch => {"+" => "-", "-" => "+", "!" => "!", "=" => "="}.freeze
         
     | 
| 
       582 
583 
     | 
    
         
             
              }.freeze
         
     | 
| 
      
 584 
     | 
    
         
            +
              # standard:enable Style/HashSyntax
         
     | 
| 
       583 
585 
     | 
    
         | 
| 
       584 
586 
     | 
    
         
             
              # Applies a +patchset+ to the sequence +src+ according to the +direction+
         
     | 
| 
       585 
587 
     | 
    
         
             
              # (<tt>:patch</tt> or <tt>:unpatch</tt>), producing a new sequence.
         
     | 
| 
         @@ -627,7 +629,7 @@ class << Diff::LCS 
     | 
|
| 
       627 
629 
     | 
    
         | 
| 
       628 
630 
     | 
    
         
             
                return src.respond_to?(:dup) ? src.dup : src unless has_changes
         
     | 
| 
       629 
631 
     | 
    
         | 
| 
       630 
     | 
    
         
            -
                string = src. 
     | 
| 
      
 632 
     | 
    
         
            +
                string = src.is_a?(String)
         
     | 
| 
       631 
633 
     | 
    
         
             
                # Start with a new empty type of the source's class
         
     | 
| 
       632 
634 
     | 
    
         
             
                res = src.class.new
         
     | 
| 
       633 
635 
     | 
    
         | 
| 
         @@ -655,14 +657,14 @@ class << Diff::LCS 
     | 
|
| 
       655 
657 
     | 
    
         
             
                    end
         
     | 
| 
       656 
658 
     | 
    
         | 
| 
       657 
659 
     | 
    
         
             
                    case action
         
     | 
| 
       658 
     | 
    
         
            -
                    when  
     | 
| 
      
 660 
     | 
    
         
            +
                    when "-" # Remove details from the old string
         
     | 
| 
       659 
661 
     | 
    
         
             
                      while ai < op
         
     | 
| 
       660 
662 
     | 
    
         
             
                        res << (string ? src[ai, 1] : src[ai])
         
     | 
| 
       661 
663 
     | 
    
         
             
                        ai += 1
         
     | 
| 
       662 
664 
     | 
    
         
             
                        bj += 1
         
     | 
| 
       663 
665 
     | 
    
         
             
                      end
         
     | 
| 
       664 
666 
     | 
    
         
             
                      ai += 1
         
     | 
| 
       665 
     | 
    
         
            -
                    when  
     | 
| 
      
 667 
     | 
    
         
            +
                    when "+"
         
     | 
| 
       666 
668 
     | 
    
         
             
                      while bj < np
         
     | 
| 
       667 
669 
     | 
    
         
             
                        res << (string ? src[ai, 1] : src[ai])
         
     | 
| 
       668 
670 
     | 
    
         
             
                        ai += 1
         
     | 
| 
         @@ -671,7 +673,7 @@ class << Diff::LCS 
     | 
|
| 
       671 
673 
     | 
    
         | 
| 
       672 
674 
     | 
    
         
             
                      res << el
         
     | 
| 
       673 
675 
     | 
    
         
             
                      bj += 1
         
     | 
| 
       674 
     | 
    
         
            -
                    when  
     | 
| 
      
 676 
     | 
    
         
            +
                    when "="
         
     | 
| 
       675 
677 
     | 
    
         
             
                      # This only appears in sdiff output with the SDiff callback.
         
     | 
| 
       676 
678 
     | 
    
         
             
                      # Therefore, we only need to worry about dealing with a single
         
     | 
| 
       677 
679 
     | 
    
         
             
                      # element.
         
     | 
| 
         @@ -679,7 +681,7 @@ class << Diff::LCS 
     | 
|
| 
       679 
681 
     | 
    
         | 
| 
       680 
682 
     | 
    
         
             
                      ai += 1
         
     | 
| 
       681 
683 
     | 
    
         
             
                      bj += 1
         
     | 
| 
       682 
     | 
    
         
            -
                    when  
     | 
| 
      
 684 
     | 
    
         
            +
                    when "!"
         
     | 
| 
       683 
685 
     | 
    
         
             
                      while ai < op
         
     | 
| 
       684 
686 
     | 
    
         
             
                        res << (string ? src[ai, 1] : src[ai])
         
     | 
| 
       685 
687 
     | 
    
         
             
                        ai += 1
         
     | 
| 
         @@ -693,14 +695,14 @@ class << Diff::LCS 
     | 
|
| 
       693 
695 
     | 
    
         
             
                    end
         
     | 
| 
       694 
696 
     | 
    
         
             
                  when Diff::LCS::Change
         
     | 
| 
       695 
697 
     | 
    
         
             
                    case action
         
     | 
| 
       696 
     | 
    
         
            -
                    when  
     | 
| 
      
 698 
     | 
    
         
            +
                    when "-"
         
     | 
| 
       697 
699 
     | 
    
         
             
                      while ai < change.position
         
     | 
| 
       698 
700 
     | 
    
         
             
                        res << (string ? src[ai, 1] : src[ai])
         
     | 
| 
       699 
701 
     | 
    
         
             
                        ai += 1
         
     | 
| 
       700 
702 
     | 
    
         
             
                        bj += 1
         
     | 
| 
       701 
703 
     | 
    
         
             
                      end
         
     | 
| 
       702 
704 
     | 
    
         
             
                      ai += 1
         
     | 
| 
       703 
     | 
    
         
            -
                    when  
     | 
| 
      
 705 
     | 
    
         
            +
                    when "+"
         
     | 
| 
       704 
706 
     | 
    
         
             
                      while bj < change.position
         
     | 
| 
       705 
707 
     | 
    
         
             
                        res << (string ? src[ai, 1] : src[ai])
         
     | 
| 
       706 
708 
     | 
    
         
             
                        ai += 1
         
     | 
| 
         @@ -736,4 +738,4 @@ class << Diff::LCS 
     | 
|
| 
       736 
738 
     | 
    
         
             
              end
         
     | 
| 
       737 
739 
     | 
    
         
             
            end
         
     | 
| 
       738 
740 
     | 
    
         | 
| 
       739 
     | 
    
         
            -
            require  
     | 
| 
      
 741 
     | 
    
         
            +
            require "diff/lcs/backports"
         
     | 
    
        data/lib/diff-lcs.rb
    CHANGED