diff options
author | Austin Ziegler <austin@surfeasy.com> | 2013-01-20 22:02:01 -0500 |
---|---|---|
committer | Austin Ziegler <austin@surfeasy.com> | 2013-01-20 22:02:01 -0500 |
commit | 3e188358d19efc4aabf3ca2999562c3cc9522e8f (patch) | |
tree | 2ea0313f8018ffda3e853054258676aaf0b767fb /lib | |
parent | ff6f32acb2f13ef3550a3ef1c38ce28e3aaf0b37 (diff) | |
download | diff-lcs-3e188358d19efc4aabf3ca2999562c3cc9522e8f.tar.gz |
Fixing an issue with Diff::LCS.lcs.
- Only on 1.8.7. Found by travis-ci.org.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/diff/lcs.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/diff/lcs.rb b/lib/diff/lcs.rb index d8b6f08..5cb58ed 100644 --- a/lib/diff/lcs.rb +++ b/lib/diff/lcs.rb @@ -221,13 +221,12 @@ class << Diff::LCS def lcs(seq1, seq2, &block) #:yields seq1[i] for each matched: matches = Diff::LCS::Internals.lcs(seq1, seq2) ret = [] + string = seq.kind_of? String matches.each_with_index do |e, i| unless matches[i].nil? - if block_given? - ret << (yield seq1[i]) - else - ret << seq1[i] - end + v = string ? seq1[i, 1] : seq1[i] + v = block[v] if block + ret << v end end ret |