[前][次][番号順一覧][スレッド一覧]

ruby-changes:46704

From: k0kubun <ko1@a...>
Date: Sat, 20 May 2017 23:55:39 +0900 (JST)
Subject: [ruby-changes:46704] k0kubun:r58819 (trunk): erb.rb: Drop unused scanner implementation

k0kubun	2017-05-20 23:55:33 +0900 (Sat, 20 May 2017)

  New Revision: 58819

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58819

  Log:
    erb.rb: Drop unused scanner implementation
    
    Original `SimpleScanner` was used only in tests.
    Since `SimpleScanner` and `SimpleScanner2` work in the same way, I want
    to drop the one which can't be used in a normal situation.
    
    The only difference was `SimpleScanner` can be loaded without strscan
    dependency but I think there's no situation that strscan is unavailable
    because it's a standard library.

  Modified files:
    trunk/lib/erb.rb
Index: lib/erb.rb
===================================================================
--- lib/erb.rb	(revision 58818)
+++ lib/erb.rb	(revision 58819)
@@ -499,22 +499,9 @@ class ERB https://github.com/ruby/ruby/blob/trunk/lib/erb.rb#L499
 
     Scanner.default_scanner = TrimScanner
 
-    class SimpleScanner < Scanner # :nodoc:
-      def scan
-        @src.scan(/(.*?)(#{(stags + etags).join('|')}|\n|\z)/m) do |tokens|
-          tokens.each do |token|
-            next if token.empty?
-            yield(token)
-          end
-        end
-      end
-    end
-
-    Scanner.regist_scanner(SimpleScanner, nil, false)
-
     begin
       require 'strscan'
-      class SimpleScanner2 < Scanner # :nodoc:
+      class SimpleScanner < Scanner # :nodoc:
         def scan
           stag_reg = /(.*?)(#{stags.join('|')}|\z)/m
           etag_reg = /(.*?)(#{etags.join('|')}|\z)/m
@@ -526,7 +513,10 @@ class ERB https://github.com/ruby/ruby/blob/trunk/lib/erb.rb#L513
           end
         end
       end
-      Scanner.regist_scanner(SimpleScanner2, nil, false)
+      Scanner.regist_scanner(SimpleScanner, nil, false)
+
+      # Deprecated. Kept for backward compatibility.
+      SimpleScanner2 = SimpleScanner # :nodoc:
 
       class ExplicitScanner < Scanner # :nodoc:
         def scan

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]