summaryrefslogtreecommitdiff
path: root/lib/diff
diff options
context:
space:
mode:
authorJon Rowe <hello@jonrowe.co.uk>2013-04-11 17:21:55 +1000
committerJon Rowe <hello@jonrowe.co.uk>2013-04-11 17:26:07 +1000
commit81367e66224e9fd0af4752f67583460df6422369 (patch)
tree24e03106a1bb376629692d79ba4d419e4b390c3c /lib/diff
parent498a97c9089ea377d85f03470ecef1c1a5c6330a (diff)
downloaddiff-lcs-81367e66224e9fd0af4752f67583460df6422369.tar.gz
protect against no data
Diffstat (limited to 'lib/diff')
-rw-r--r--lib/diff/lcs/hunk.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/diff/lcs/hunk.rb b/lib/diff/lcs/hunk.rb
index 6c5ea6a..05c3fb6 100644
--- a/lib/diff/lcs/hunk.rb
+++ b/lib/diff/lcs/hunk.rb
@@ -12,7 +12,7 @@ class Diff::LCS::Hunk
# At first, a hunk will have just one Block in it
@blocks = [ Diff::LCS::Block.new(piece) ]
if String.method_defined?(:encoding)
- @preferred_data_encoding = data_old[0].encoding
+ @preferred_data_encoding = data_old.fetch(0, data_new.fetch(0,'') ).encoding
end
@data_old = data_old
@data_new = data_new