summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-25 04:44:32 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-25 04:44:32 +0000
commitc6cb78def2ffd07a15854a66128c4d9910f014ac (patch)
tree035c72dcd722f8f86f9b396a4f7b6ffe39847c62 /lib
parent82208b8b9b85e32f54cf6ca827c4ec045ecf3557 (diff)
downloadruby-c6cb78def2ffd07a15854a66128c4d9910f014ac.tar.gz
ruby-c6cb78def2ffd07a15854a66128c4d9910f014ac.tar.xz
ruby-c6cb78def2ffd07a15854a66128c4d9910f014ac.zip
* lib/erb.rb (ERB::Compiler:Buffer#new): push magic comment first.
* lib/erb.rb (ERB::Compiler#compile): fix for broken input. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@17569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/erb.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/erb.rb b/lib/erb.rb
index e1f078285..d48d00ac3 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -486,10 +486,10 @@ class ERB
end
class Buffer # :nodoc:
- def initialize(compiler)
+ def initialize(compiler, enc=nil)
@compiler = compiler
@line = []
- @script = ""
+ @script = enc ? "#coding:#{enc.to_s}\n" : ""
@compiler.pre_cmd.each do |x|
push(x)
end
@@ -517,11 +517,10 @@ class ERB
end
def compile(s)
- out = Buffer.new(self)
- out.push("# -*- coding: #{s.encoding} -*-\n")
+ out = Buffer.new(self, s.encoding)
content = ''
- scanner = make_scanner(s)
+ scanner = make_scanner(s.dup.force_encoding("ASCII-8BIT"))
scanner.scan do |token|
if scanner.stag.nil?
case token