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

ruby-changes:35913

From: nobu <ko1@a...>
Date: Fri, 17 Oct 2014 15:30:17 +0900 (JST)
Subject: [ruby-changes:35913] nobu:r47994 (trunk): erb: multiline anchors

nobu	2014-10-17 15:30:08 +0900 (Fri, 17 Oct 2014)

  New Revision: 47994

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

  Log:
    erb: multiline anchors
    
    * bin/erb (ARGV.switch, ERB::Main#run): use beginning/end of
      string anchors instead of beginning/end of line anchors.

  Modified files:
    trunk/bin/erb
Index: bin/erb
===================================================================
--- bin/erb	(revision 47993)
+++ bin/erb	(revision 47994)
@@ -11,7 +11,8 @@ class ERB https://github.com/ruby/ruby/blob/trunk/bin/erb#L11
       return nil if self.empty?
       arg = self.shift
       return nil if arg == '--'
-      if arg =~ /^-(.)(.*)/
+      case arg
+      when /\A-(.)(.*)/
         if $1 == '-'
           arg, @maybe_arg = arg.split(/=/, 2)
           return arg
@@ -72,7 +73,7 @@ class ERB https://github.com/ruby/ruby/blob/trunk/bin/erb#L73
             require ARGV.req_arg
           when '-S'                        # security level
             arg = ARGV.req_arg
-            raise "invalid safe_level #{arg.dump}" unless arg =~ /^[0-3]$/
+            raise "invalid safe_level #{arg.dump}" unless arg =~ /\A[0-3]\z/
             safe_level = arg.to_i
           when '-T'                        # trim mode
             arg = ARGV.req_arg
@@ -80,7 +81,7 @@ class ERB https://github.com/ruby/ruby/blob/trunk/bin/erb#L81
               trim_mode = arg
               next
             end
-            raise "invalid trim mode #{arg.dump}" unless arg =~ /^[0-2]$/
+            raise "invalid trim mode #{arg.dump}" unless arg =~ /\A[0-2]\z/
             trim_mode = arg.to_i
           when '-E', '--encoding'
             arg = ARGV.req_arg

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

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