ruby-changes:6059
From: naruse <ko1@a...>
Date: Wed, 25 Jun 2008 13:45:28 +0900 (JST)
Subject: [ruby-changes:6059] Ruby:r17569 (trunk): * lib/erb.rb (ERB::Compiler:Buffer#new): push magic comment first.
naruse 2008-06-25 13:44:32 +0900 (Wed, 25 Jun 2008) New Revision: 17569 Modified files: trunk/ChangeLog trunk/lib/erb.rb Log: * lib/erb.rb (ERB::Compiler:Buffer#new): push magic comment first. * lib/erb.rb (ERB::Compiler#compile): fix for broken input. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17569&r2=17568&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/erb.rb?r1=17569&r2=17568&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 17568) +++ ChangeLog (revision 17569) @@ -1,3 +1,9 @@ +Wed Jun 25 13:42:44 2008 NARUSE, Yui <naruse@r...> + + * 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@r...> * lib/erb.rb (ERB::Compiler#compile): magic comment needs LF. Index: lib/erb.rb =================================================================== --- lib/erb.rb (revision 17568) +++ lib/erb.rb (revision 17569) @@ -486,10 +486,10 @@ 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 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/