Permalink
Browse files

Runner: don't invoke force_encoding in 1.8 (fixes #133).

  • Loading branch information...
1 parent 759362f commit 0311bfd719ed6bb40a8ff7025ac48c52503493e9 @whitequark committed Feb 24, 2014
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/parser/runner.rb
@@ -145,7 +145,9 @@ def process_all_input
def process_fragments
@fragments.each_with_index do |fragment, index|
- fragment = fragment.dup.force_encoding(@parser.default_encoding)
+ if fragment.respond_to? :force_encoding
+ fragment = fragment.dup.force_encoding(@parser.default_encoding)
+ end
buffer = Source::Buffer.new("(fragment:#{index})")
buffer.source = fragment
@@ -157,7 +159,9 @@ def process_fragments
def process_files
@files.each do |filename|
source = File.read(filename)
- source.force_encoding(@parser.default_encoding)
+ if source.respond_to? :force_encoding
+ source.force_encoding(@parser.default_encoding)
+ end
buffer = Parser::Source::Buffer.new(filename)

0 comments on commit 0311bfd

Please sign in to comment.