1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/erb.rb (ERB::Compiler:Buffer#new): push magic comment first.

* lib/erb.rb (ERB::Compiler#compile): fix for broken input.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2008-06-25 04:44:32 +00:00
parent 30e263fc07
commit f94c46a745
2 changed files with 10 additions and 5 deletions

View file

@ -1,3 +1,9 @@
Wed Jun 25 13:42:44 2008 NARUSE, Yui <naruse@ruby-lang.org>
* lib/erb.rb (ERB::Compiler:Buffer#new): push magic comment first.
* lib/erb.rb (ERB::Compiler#compile): fix for broken input.
Wed Jun 25 12:10:01 2008 NARUSE, Yui <naruse@ruby-lang.org> Wed Jun 25 12:10:01 2008 NARUSE, Yui <naruse@ruby-lang.org>
* lib/erb.rb (ERB::Compiler#compile): magic comment needs LF. * lib/erb.rb (ERB::Compiler#compile): magic comment needs LF.

View file

@ -486,10 +486,10 @@ class ERB
end end
class Buffer # :nodoc: class Buffer # :nodoc:
def initialize(compiler) def initialize(compiler, enc=nil)
@compiler = compiler @compiler = compiler
@line = [] @line = []
@script = "" @script = enc ? "#coding:#{enc.to_s}\n" : ""
@compiler.pre_cmd.each do |x| @compiler.pre_cmd.each do |x|
push(x) push(x)
end end
@ -517,11 +517,10 @@ class ERB
end end
def compile(s) def compile(s)
out = Buffer.new(self) out = Buffer.new(self, s.encoding)
out.push("# -*- coding: #{s.encoding} -*-\n")
content = '' content = ''
scanner = make_scanner(s) scanner = make_scanner(s.dup.force_encoding("ASCII-8BIT"))
scanner.scan do |token| scanner.scan do |token|
if scanner.stag.nil? if scanner.stag.nil?
case token case token