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

ruby-changes:9342

From: yugui <ko1@a...>
Date: Fri, 19 Dec 2008 20:38:22 +0900 (JST)
Subject: [ruby-changes:9342] Ruby:r20880 (ruby_1_9_1): merges r20859 from trunk into ruby_1_9_1.

yugui	2008-12-19 20:37:41 +0900 (Fri, 19 Dec 2008)

  New Revision: 20880

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

  Log:
    merges r20859 from trunk into ruby_1_9_1.
    * lib/optparse/version.rb: remove variable shadowing to stop
      warning.   [ruby-core:20612]
    * lib/irb/completion.rb, lib/net/imap.rb, lib/prime.rb,
      lib/rinda/ring.rb, lib/racc/parser.rb,
      lib/shell/command-processor.rb, lib/yaml/yamlnode.rb: ditto.
    
    * lib/racc/parser.rb: remove space before parentheses.
    
    * lib/shell/command-processor.rb, lib/shell/process-controller.rb:
      use parentheses around arguments.
    
    * lib/irb/ext/change-ws.rb, lib/rexml/validation/relaxng.rb,
      lib/yaml/baseemitter.rb: indentation fix.
    
    * lib/matrix.rb: small cosmetic change.

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/lib/irb/completion.rb
    branches/ruby_1_9_1/lib/irb/ext/change-ws.rb
    branches/ruby_1_9_1/lib/matrix.rb
    branches/ruby_1_9_1/lib/net/imap.rb
    branches/ruby_1_9_1/lib/optparse/version.rb
    branches/ruby_1_9_1/lib/prime.rb
    branches/ruby_1_9_1/lib/racc/parser.rb
    branches/ruby_1_9_1/lib/rexml/validation/relaxng.rb
    branches/ruby_1_9_1/lib/rinda/ring.rb
    branches/ruby_1_9_1/lib/shell/command-processor.rb
    branches/ruby_1_9_1/lib/shell/process-controller.rb
    branches/ruby_1_9_1/lib/yaml/baseemitter.rb
    branches/ruby_1_9_1/lib/yaml/yamlnode.rb

Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 20879)
+++ ruby_1_9_1/ChangeLog	(revision 20880)
@@ -1,3 +1,22 @@
+Thu Dec 18 16:48:12 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* lib/optparse/version.rb: remove variable shadowing to stop
+	  warning.   [ruby-core:20612]
+
+	* lib/irb/completion.rb, lib/net/imap.rb, lib/prime.rb,
+	  lib/rinda/ring.rb, lib/racc/parser.rb,
+	  lib/shell/command-processor.rb, lib/yaml/yamlnode.rb: ditto.
+
+	* lib/racc/parser.rb: remove space before parentheses.
+
+	* lib/shell/command-processor.rb, lib/shell/process-controller.rb:
+	  use parentheses around arguments.
+
+	* lib/irb/ext/change-ws.rb, lib/rexml/validation/relaxng.rb,
+	  lib/yaml/baseemitter.rb: indentation fix.
+
+	* lib/matrix.rb: small cosmetic change.
+
 Thu Dec 18 08:15:04 2008  James Edward Gray II  <jeg2@r...>
 
 	* lib/xmlrpc/server.rb:  Restricting method inspection to show only
Index: ruby_1_9_1/lib/rexml/validation/relaxng.rb
===================================================================
--- ruby_1_9_1/lib/rexml/validation/relaxng.rb	(revision 20879)
+++ ruby_1_9_1/lib/rexml/validation/relaxng.rb	(revision 20880)
@@ -436,7 +436,7 @@
 
             arry[-1][-1].event_arg = evt[1]
             @value = false
-          end
+         end
         else
           arry << [] if evt[0] == :start_element
           arry[-1] << generate_event( evt )
Index: ruby_1_9_1/lib/irb/ext/change-ws.rb
===================================================================
--- ruby_1_9_1/lib/irb/ext/change-ws.rb	(revision 20879)
+++ ruby_1_9_1/lib/irb/ext/change-ws.rb	(revision 20880)
@@ -56,6 +56,6 @@
 #       end
 #     end
 #     alias change_workspace change_binding
-   end
+  end
 end
 
Index: ruby_1_9_1/lib/irb/completion.rb
===================================================================
--- ruby_1_9_1/lib/irb/completion.rb	(revision 20879)
+++ ruby_1_9_1/lib/irb/completion.rb	(revision 20880)
@@ -159,7 +159,7 @@
 	    end
 	    next if name != "IRB::Context" and 
 	      /^(IRB|SLex|RubyLex|RubyToken)/ =~ name
-	    candidates.concat m.instance_methods(false).collect{|m| m.to_s}
+	    candidates.concat m.instance_methods(false).collect{|x| x.to_s}
 	  }
 	  candidates.sort!
 	  candidates.uniq!
Index: ruby_1_9_1/lib/optparse/version.rb
===================================================================
--- ruby_1_9_1/lib/optparse/version.rb	(revision 20879)
+++ ruby_1_9_1/lib/optparse/version.rb	(revision 20880)
@@ -1,7 +1,7 @@
 # OptionParser internal utility
 
 class << OptionParser
-  def show_version(*pkg)
+  def show_version(*pkgs)
     progname = ARGV.options.program_name
     result = false
     show = proc do |klass, cname, version|
@@ -19,14 +19,14 @@
       puts str
       result = true
     end
-    if pkg.size == 1 and pkg[0] == "all"
+    if pkgs.size == 1 and pkgs[0] == "all"
       self.search_const(::Object, /\AV(?:ERSION|ersion)\z/) do |klass, cname, version|
         unless cname[1] == ?e and klass.const_defined?(:Version)
           show.call(klass, cname.intern, version)
         end
       end
     else
-      pkg.each do |pkg|
+      pkgs.each do |pkg|
         begin
           pkg = pkg.split(/::|\//).inject(::Object) {|m, c| m.const_get(c)}
           v = case
@@ -46,8 +46,8 @@
     result
   end
 
-  def each_const(path, klass = ::Object)
-    path.split(/::|\//).inject(klass) do |klass, name|
+  def each_const(path, base = ::Object)
+    path.split(/::|\//).inject(base) do |klass, name|
       raise NameError, path unless Module === klass
       klass.constants.grep(/#{name}/i) do |c|
         klass.const_defined?(c) or next
Index: ruby_1_9_1/lib/shell/process-controller.rb
===================================================================
--- ruby_1_9_1/lib/shell/process-controller.rb	(revision 20879)
+++ ruby_1_9_1/lib/shell/process-controller.rb	(revision 20880)
@@ -62,7 +62,7 @@
       end
 
       def block_output_synchronize(&b)
-	@BlockOutputMonitor.synchronize &b
+	@BlockOutputMonitor.synchronize(&b)
       end
 
       def wait_to_finish_all_process_controllers
Index: ruby_1_9_1/lib/shell/command-processor.rb
===================================================================
--- ruby_1_9_1/lib/shell/command-processor.rb	(revision 20879)
+++ ruby_1_9_1/lib/shell/command-processor.rb	(revision 20880)
@@ -26,7 +26,7 @@
     #
     m = [:initialize, :expand_path]
     if Object.methods.first.kind_of?(String)
-      NoDelegateMethods = m.collect{|m| m.id2name}
+      NoDelegateMethods = m.collect{|x| x.id2name}
     else
       NoDelegateMethods = m
     end
@@ -124,7 +124,7 @@
 	  f = File.open(path, mode, perm)
 	  File.chmod(perm & ~@shell.umask, path)
 	  if block_given?
-	    f.each &b
+	    f.each(&b)
 	  end
 	  f
 	else
Index: ruby_1_9_1/lib/prime.rb
===================================================================
--- ruby_1_9_1/lib/prime.rb	(revision 20879)
+++ ruby_1_9_1/lib/prime.rb	(revision 20880)
@@ -411,8 +411,8 @@
       loop do
 	extend_table until @table.length > i
 	if !@table[i].zero?
-	  (j...32).step(2) do |j|
-	    return 32*i+j if !@table[i][j.div(2)].zero?
+	  (j...32).step(2) do |k|
+	    return 32*i+k if !@table[i][k.div(2)].zero?
 	  end
 	end
 	i += 1; j = 1
Index: ruby_1_9_1/lib/net/imap.rb
===================================================================
--- ruby_1_9_1/lib/net/imap.rb	(revision 20879)
+++ ruby_1_9_1/lib/net/imap.rb	(revision 20880)
@@ -3216,7 +3216,7 @@
 	    ].join(':')
 	  )
 
-	  return response.keys.map { |k| qdval(k.to_s, response[k]) }.join(',')
+	  return response.keys.map {|key| qdval(key.to_s, response[key]) }.join(',')
 	when STAGE_TWO
 	  @stage = nil
 	  # if at the second stage, return an empty string
Index: ruby_1_9_1/lib/rinda/ring.rb
===================================================================
--- ruby_1_9_1/lib/rinda/ring.rb	(revision 20879)
+++ ruby_1_9_1/lib/rinda/ring.rb	(revision 20880)
@@ -256,15 +256,15 @@
     $stdin.gets
   when 'w'
     finger = Rinda::RingFinger.new(nil)
-    finger.lookup_ring do |ts|
-      p ts
-      ts.write([:hello, :world])
+    finger.lookup_ring do |ts2|
+      p ts2
+      ts2.write([:hello, :world])
     end
   when 'r'
     finger = Rinda::RingFinger.new(nil)
-    finger.lookup_ring do |ts|
-      p ts
-      p ts.take([nil, nil])
+    finger.lookup_ring do |ts2|
+      p ts2
+      p ts2.take([nil, nil])
     end
   end
 end
Index: ruby_1_9_1/lib/yaml/baseemitter.rb
===================================================================
--- ruby_1_9_1/lib/yaml/baseemitter.rb	(revision 20879)
+++ ruby_1_9_1/lib/yaml/baseemitter.rb	(revision 20880)
@@ -7,241 +7,236 @@
 require 'yaml/error'
 
 module YAML
+  module BaseEmitter
+    def options( opt = nil )
+      if opt
+        @options[opt] || YAML::DEFAULTS[opt]
+      else
+        @options
+      end
+    end
 
-    module BaseEmitter
+    def options=( opt )
+      @options = opt
+    end
 
-        def options( opt = nil )
-            if opt
-                @options[opt] || YAML::DEFAULTS[opt]
-            else
-                @options
-            end
-        end
+    #
+    # Emit binary data
+    #
+    def binary_base64( value )
+      self << "!binary "
+      self.node_text( [value].pack("m"), '|' )
+    end
 
-        def options=( opt )
-            @options = opt
+    #
+    # Emit plain, normal flowing text
+    #
+    def node_text( value, block = nil )
+      @seq_map = false
+      valx = value.dup
+      unless block
+        block =
+          if options(:UseBlock)
+            '|'
+          elsif not options(:UseFold) and valx =~ /\n[ \t]/ and not valx =~ /#{YAML::ESCAPE_CHAR}/
+            '|'
+          else
+            '>'
+          end 
+        indt = $&.to_i if block =~ /\d+/
+        if valx =~ /(\A\n*[ \t#]|^---\s+)/
+          indt = options(:Indent) unless indt.to_i > 0
+          block += indt.to_s
         end
 
-        #
-        # Emit binary data
-        #
-        def binary_base64( value )
-            self << "!binary "
-            self.node_text( [value].pack("m"), '|' )
+        block +=
+          if valx =~ /\n\Z\n/
+            "+"
+          elsif valx =~ /\Z\n/
+            ""
+          else
+            "-"
+          end
+      end
+      block += "\n"
+      if block[0] == ?"
+        esc_skip = ( "\t\n" unless valx =~ /^[ \t]/ ) || ""
+        valx = fold( YAML::escape( valx, esc_skip ) + "\"" ).chomp
+        self << '"' + indent_text( valx, indt, false )
+      else
+        if block[0] == ?> 
+          valx = fold( valx ) 
         end
+        #p [block, indt]
+        self << block + indent_text( valx, indt )
+      end
+    end
 
-		#
-		# Emit plain, normal flowing text
-		#
-		def node_text( value, block = nil )
-            @seq_map = false
-			valx = value.dup
-            unless block
-            block =
-                if options(:UseBlock)
-                    '|'
-                elsif not options(:UseFold) and valx =~ /\n[ \t]/ and not valx =~ /#{YAML::ESCAPE_CHAR}/
-                    '|'
-                else
-                    '>'
-                end 
+    #
+    # Emit a simple, unqouted string
+    #
+    def simple( value )
+      @seq_map = false
+      self << value.to_s
+    end
 
-                indt = $&.to_i if block =~ /\d+/
-                if valx =~ /(\A\n*[ \t#]|^---\s+)/
-                    indt = options(:Indent) unless indt.to_i > 0
-                    block += indt.to_s
-                end
+    #
+    # Emit double-quoted string
+    #
+    def double( value )
+      "\"#{YAML.escape( value )}\"" 
+    end
 
-            block +=
-                if valx =~ /\n\Z\n/
-                    "+"
-                elsif valx =~ /\Z\n/
-                    ""
-                else
-                    "-"
-                end
-            end
-            block += "\n"
-            if block[0] == ?"
-                esc_skip = ( "\t\n" unless valx =~ /^[ \t]/ ) || ""
-                valx = fold( YAML::escape( valx, esc_skip ) + "\"" ).chomp
-                self << '"' + indent_text( valx, indt, false )
-            else
-                if block[0] == ?> 
-                    valx = fold( valx ) 
-                end
-                #p [block, indt]
-                self << block + indent_text( valx, indt )
-            end
-		end
+    #
+    # Emit single-quoted string
+    #
+    def single( value )
+      "'#{value}'"
+    end
 
-		#
-		# Emit a simple, unqouted string
-		#
-		def simple( value )
-            @seq_map = false
-            self << value.to_s
-		end
+    #
+    # Write a text block with the current indent
+    #
+    def indent_text( text, mod, first_line = true )
+      return "" if text.to_s.empty?
+      spacing = indent( mod )
+      text = text.gsub( /\A([^\n])/, "#{ spacing }\\1" ) if first_line
+      return text.gsub( /\n^([^\n])/, "\n#{spacing}\\1" )
+    end
 
-		#
-		# Emit double-quoted string
-		#
-		def double( value )
-			"\"#{YAML.escape( value )}\"" 
-		end
+    #
+    # Write a current indent
+    #
+    def indent( mod = nil )
+      #p [ self.id, level, mod, :INDENT ]
+      if level <= 0
+        mod ||= 0
+      else
+        mod ||= options(:Indent)
+        mod += ( level - 1 ) * options(:Indent)
+      end
+      return " " * mod
+    end
 
-		#
-		# Emit single-quoted string
-		#
-		def single( value )
-			"'#{value}'"
-		end
+    #
+    # Add indent to the buffer
+    #
+    def indent!
+      self << indent
+    end
 
-		#
-		# Write a text block with the current indent
-		#
-		def indent_text( text, mod, first_line = true )
-			return "" if text.to_s.empty?
-            spacing = indent( mod )
-            text = text.gsub( /\A([^\n])/, "#{ spacing }\\1" ) if first_line
-			return text.gsub( /\n^([^\n])/, "\n#{spacing}\\1" )
-		end
+    #
+    # Folding paragraphs within a column
+    #
+    def fold( value )
+      value.gsub( /(^[ \t]+.*$)|(\S.{0,#{options(:BestWidth) - 1}})(?:[ \t]+|(\n+(?=[ \t]|\Z))|$)/ ) do
+        $1 || $2 + ( $3 || "\n" )
+      end
+    end
 
-		#
-		# Write a current indent
-		#
-        def indent( mod = nil )
-            #p [ self.id, level, mod, :INDENT ]
-            if level <= 0
-                mod ||= 0
-            else
-                mod ||= options(:Indent)
-                mod += ( level - 1 ) * options(:Indent)
-            end
-            return " " * mod
-		end
+    #
+    # Quick mapping
+    #
+    def map( type, &e )
+      val = Mapping.new
+      e.call( val )
+      self << "#{type} " if type.length.nonzero?
 
-		#
-		# Add indent to the buffer
-		#
-		def indent!
-			self << indent
-		end
+      #
+      # Empty hashes
+      #
+      if val.length.zero?
+        self << "{}"
+        @seq_map = false
+      else
+        # FIXME
+        # if @buffer.length == 1 and options(:UseHeader) == false and type.length.zero? 
+        #     @headless = 1 
+        # end
 
-		#
-		# Folding paragraphs within a column
-		#
-		def fold( value )
-            value.gsub( /(^[ \t]+.*$)|(\S.{0,#{options(:BestWidth) - 1}})(?:[ \t]+|(\n+(?=[ \t]|\Z))|$)/ ) do
-                $1 || $2 + ( $3 || "\n" )
-            end
-		end
+        defkey = @options.delete( :DefaultKey )
+        if defkey
+          seq_map_shortcut
+          self << "= : "
+          defkey.to_yaml( :Emitter => self )
+        end
 
         #
-        # Quick mapping
+        # Emit the key and value
         #
-        def map( type, &e )
-            val = Mapping.new
-            e.call( val )
-			self << "#{type} " if type.length.nonzero?
+        val.each { |v|
+          seq_map_shortcut
+          if v[0].is_complex_yaml?
+            self << "? "
+          end
+          v[0].to_yaml( :Emitter => self )
+          if v[0].is_complex_yaml?
+            self << "\n"
+            indent!
+          end
+          self << ": " 
+          v[1].to_yaml( :Emitter => self )
+        }
+      end
+    end
 
-			#
-			# Empty hashes
-			#
-			if val.length.zero?
-				self << "{}"
-                @seq_map = false
-			else
-                # FIXME
-                # if @buffer.length == 1 and options(:UseHeader) == false and type.length.zero? 
-			    #     @headless = 1 
-                # end
+    def seq_map_shortcut
+      # FIXME: seq_map needs to work with the new anchoring system
+      # if @seq_map
+      #     @anchor_extras[@buffer.length - 1] = "\n" + indent
+      #     @seq_map = false
+      # else
+      self << "\n"
+      indent! 
+      # end
+    end
 
-                defkey = @options.delete( :DefaultKey )
-                if defkey
-                    seq_map_shortcut
-                    self << "= : "
-                    defkey.to_yaml( :Emitter => self )
-                end
+    #
+    # Quick sequence
+    #
+    def seq( type, &e )
+      @seq_map = false
+      val = Sequence.new
+      e.call( val )
+      self << "#{type} " if type.length.nonzero?
 
-				#
-				# Emit the key and value
-				#
-                val.each { |v|
-                    seq_map_shortcut
-                    if v[0].is_complex_yaml?
-                        self << "? "
-                    end
-                    v[0].to_yaml( :Emitter => self )
-                    if v[0].is_complex_yaml?
-                        self << "\n"
-                        indent!
-                    end
-                    self << ": " 
-                    v[1].to_yaml( :Emitter => self )
-                }
-			end
-        end
+      #
+      # Empty arrays
+      #
+      if val.length.zero?
+        self << "[]"
+      else
+        # FIXME
+        # if @buffer.length == 1 and options(:UseHeader) == false and type.length.zero? 
+        #     @headless = 1 
+        # end
 
-        def seq_map_shortcut
-            # FIXME: seq_map needs to work with the new anchoring system
-            # if @seq_map
-            #     @anchor_extras[@buffer.length - 1] = "\n" + indent
-            #     @seq_map = false
-            # else
-                self << "\n"
-                indent! 
-            # end
-        end
-
         #
-        # Quick sequence
+        # Emit the key and value
         #
-        def seq( type, &e )
-            @seq_map = false
-            val = Sequence.new
-            e.call( val )
-			self << "#{type} " if type.length.nonzero?
-
-			#
-			# Empty arrays
-			#
-			if val.length.zero?
-				self << "[]"
-			else
-                # FIXME
-                # if @buffer.length == 1 and options(:UseHeader) == false and type.length.zero? 
-			    #     @headless = 1 
-                # end
-
-				#
-				# Emit the key and value
-				#
-                val.each { |v|
-                    self << "\n"
-                    indent!
-                    self << "- "
-                    @seq_map = true if v.class == Hash
-                    v.to_yaml( :Emitter => self )
-                }
-			end
-        end
-
+        val.each { |v|
+          self << "\n"
+          indent!
+          self << "- "
+          @seq_map = true if v.class == Hash
+          v.to_yaml( :Emitter => self )
+        }
+      end
     end
+  end
 
-    #
-    # Emitter helper classes
-    #
-    class Mapping < Array
-        def add( k, v )
-            push [k, v]
-        end
+  #
+  # Emitter helper classes
+  #
+  class Mapping < Array
+    def add( k, v )
+      push [k, v]
     end
+  end
 
-    class Sequence < Array
-        def add( v )
-            push v
-        end
+  class Sequence < Array
+    def add( v )
+      push v
     end
-
+  end
 end
Index: ruby_1_9_1/lib/yaml/yamlnode.rb
===================================================================
--- ruby_1_9_1/lib/yaml/yamlnode.rb	(revision 20879)
+++ ruby_1_9_1/lib/yaml/yamlnode.rb	(revision 20880)
@@ -11,13 +11,13 @@
     class YamlNode
         include BaseNode
         attr_accessor :kind, :type_id, :value, :anchor
-        def initialize( t, v )
+        def initialize(t, v)
             @type_id = t
             if Hash === v
                 @kind = 'map'
                 @value = {}
-                v.each { |k,v|
-                    @value[ k.transform ] = [ k, v ]
+                v.each {|key,val|
+                    @value[key.transform] = [key, val]
                 }
             elsif Array === v
                 @kind = 'seq'
Index: ruby_1_9_1/lib/matrix.rb
===================================================================
--- ruby_1_9_1/lib/matrix.rb	(revision 20879)
+++ ruby_1_9_1/lib/matrix.rb	(revision 20880)
@@ -140,10 +140,8 @@
   #
   #
   def Matrix.columns(columns)
-    rows = (0 .. columns[0].size - 1).collect {
-      |i|
-      (0 .. columns.size - 1).collect {
-        |j|
+    rows = (0 .. columns[0].size - 1).collect {|i|
+      (0 .. columns.size - 1).collect {|j|
         columns[j][i]
       }
     }
@@ -159,8 +157,7 @@
   #
   def Matrix.diagonal(*values)
     size = values.size
-    rows = (0 .. size  - 1).collect {
-      |j|
+    rows = (0 .. size  - 1).collect {|j|
       row = Array.new(size).fill(0, 0, size)
       row[j] = values[j]
       row
@@ -311,13 +308,11 @@
   #
   def column(j) # :yield: e
     if block_given?
-      0.upto(row_size - 1) do
-        |i|
+      0.upto(row_size - 1) do |i|
         yield @rows[i][j]
       end
     else
-      col = (0 .. row_size - 1).collect {
-        |i|
+      col = (0 .. row_size - 1).collect {|i|
         @rows[i][j]
       }
       Vector.elements(col, false)
@@ -364,8 +359,7 @@
       Matrix.Raise ArgumentError, param.inspect
     end
     
-    rows = @rows[from_row, size_row].collect{
-      |row|
+    rows = @rows[from_row, size_row].collect{|row|
       row[from_col, size_col]
     }
     Matrix.rows(rows, false)
@@ -421,8 +415,7 @@
   def compare_by_row_vectors(rows, comparison = :==)
     return false unless @rows.size == rows.size
     
-    0.upto(@rows.size - 1) do
-      |i|
+    0.upto(@rows.size - 1) do |i|
       return false unless @rows[i].send(comparison, rows[i])
     end
     true
@@ -462,10 +455,8 @@
   def *(m) # m is matrix or vector or number
     case(m)
     when Numeric
-      rows = @rows.collect {
-        |row|
-        row.collect {
-          |e|
+      rows = @rows.collect {|row|
+        row.collect {|e|
           e * m
         }
       }
@@ -477,13 +468,10 @@
     when Matrix
       Matrix.Raise ErrDimensionMismatch if column_size != m.row_size
     
-      rows = (0 .. row_size - 1).collect {
-        |i|
-        (0 .. m.column_size - 1).collect {
-          |j|
+      rows = (0 .. row_size - 1).collect {|i|
+        (0 .. m.column_size - 1).collect {|j|
           vij = 0
-          0.upto(column_size - 1) do
-            |k|
+          0.upto(column_size - 1) do |k|
             vij += self[i, k] * m[k, j]
           end
           vij
@@ -516,10 +504,8 @@
     
     Matrix.Raise ErrDimensionMismatch unless row_size == m.row_size and column_size == m.column_size
     
-    rows = (0 .. row_size - 1).collect {
-      |i|
-      (0 .. column_size - 1).collect {
-        |j|
+    rows = (0 .. row_size - 1).collect {|i|
+      (0 .. column_size - 1).collect {|j|
         self[i, j] + m[i, j]
       }
     }
@@ -546,10 +532,8 @@
     
     Matrix.Raise ErrDimensionMismatch unless row_size == m.row_size and column_size == m.column_size
     
-    rows = (0 .. row_size - 1).collect {
-      |i|
-      (0 .. column_size - 1).collect {
-        |j|
+    rows = (0 .. row_size - 1).collect {|i|
+      (0 .. column_size - 1).collect {|j|
         self[i, j] - m[i, j]
       }
     }
@@ -565,10 +549,8 @@
   def /(other)
     case other
     when Numeric
-      rows = @rows.collect {
-        |row|
-        row.collect {
-          |e|
+      rows = @rows.collect {|row|
+        row.collect {|e|
           e / other
         }
       }
@@ -603,7 +585,7 @@
     for k in 0..size
       i = k
       akk = a[k][k].abs
-      for j in (k+1)..size
+      ((k+1)..size).each do |j|
         v = a[j][k].abs
         if v > akk
           i = j
@@ -697,12 +679,13 @@
     
     det = 1
     k = 0
-    begin 
+    loop do
       if (akk = a[k][k]) == 0
         i = k
-        begin
-          return 0 if (i += 1) > size
-        end while a[i][k] == 0
+        loop do
+          return 0 if (ii += 1) > size
+          break unless a[i][k] == 0
+        end
         a[i], a[k] = a[k], a[i]
         akk = a[k][k]
         det *= -1
@@ -710,13 +693,13 @@
 
       for i in k + 1 .. size
         q = a[i][k].quo(akk)
-        (k + 1).upto(size) do
-          |j|
+        (k + 1).upto(size) do |j|
           a[i][j] -= a[k][j] * q
         end
       end
       det *= akk
-    end while (k += 1) <= size
+      break unless (k += 1) <= size
+    end
     det
   end
   alias det determinant
@@ -739,12 +722,13 @@
     
     det = 1
     k = 0
-    begin 
+    loop do
       if a[k][k].zero?
         i = k
-        begin
+        loop do
           return 0 if (i += 1) > size
-        end while a[i][k].zero?
+          break unless a[i][k].zero?
+        end
         a[i], a[k] = a[k], a[i]
         det *= -1
       end
@@ -761,7 +745,8 @@
         end
       end
       det *= a[k][k]
-    end while (k += 1) <= size
+      break unless (k += 1) <= size
+    end
     det
   end
   alias det_e determinant_e
@@ -786,31 +771,32 @@
     end
     rank = 0
     k = 0
-    begin
+    loop do
       if (akk = a[k][k]) == 0
         i = k
         exists = true
-        begin
+        loop do
           if (i += 1) > a_column_size - 1
             exists = false
             break
           end
-        end while a[i][k] == 0
+          break unless a[i][k] == 0
+        end
         if exists
           a[i], a[k] = a[k], a[i]
           akk = a[k][k]
         else
           i = k
           exists = true
-          begin
+          loop do
             if (i += 1) > a_row_size - 1
               exists = false
               break
             end
-          end while a[k][i] == 0
+            break unless a[k][i] == 0
+          end
           if exists
-            k.upto(a_column_size - 1) do
-              |j|
+            k.upto(a_column_size - 1) do |j|
               a[j][k], a[j][i] = a[j][i], a[j][k]
             end
             akk = a[k][k]
@@ -827,7 +813,8 @@
         end
       end
       rank += 1
-    end while (k += 1) <= a_column_size - 1
+      break unless (k += 1) <= a_column_size - 1
+    end
     return rank
   end
 
@@ -873,8 +860,7 @@
   #
   def trace
     tr = 0
-    0.upto(column_size - 1) do
-      |i|
+    0.upto(column_size - 1) do |i|
       tr += @rows[i][i]
     end
     tr
@@ -916,8 +902,7 @@
   # Returns an array of the row vectors of the matrix.  See Vector.
   #
   def row_vectors
-    rows = (0 .. row_size - 1).collect {
-      |i|
+    rows = (0 .. row_size - 1).collect {|i|
       row(i)
     }
     rows
@@ -927,8 +912,7 @@
   # Returns an array of the column vectors of the matrix.  See Vector.
   #
   def column_vectors
-    columns = (0 .. column_size - 1).collect {
-      |i|
+    columns = (0 .. column_size - 1).collect {|i|
       column(i)
     }
     columns
@@ -961,8 +945,7 @@
   # Overrides Object#to_s
   #
   def to_s
-    "Matrix[" + @rows.collect{
-      |row|
+    "Matrix[" + @rows.collect{|row|
       "[" + row.collect{|e| e.to_s}.join(", ") + "]"
     }.join(", ")+"]"
   end
@@ -1169,8 +1152,7 @@
   #
   def each2(v) # :yield: e1, e2
     Vector.Raise ErrDimensionMismatch if size != v.size
-    0.upto(size - 1) do
-      |i|
+    0.upto(size - 1) do |i|
       yield @elements[i], v[i]
     end
   end
@@ -1181,8 +1163,7 @@
   #
   def collect2(v) # :yield: e1, e2
     Vector.Raise ErrDimensionMismatch if size != v.size
-    (0 .. size - 1).collect do
-      |i|
+    (0 .. size - 1).collect do |i|
       yield @elements[i], v[i]
     end
   end
@@ -1253,8 +1234,7 @@
     case v
     when Vector
       Vector.Raise ErrDimensionMismatch if size != v.size
-      els = collect2(v) {
-        |v1, v2|
+      els = collect2(v) {|v1, v2|
         v1 + v2
       }
       Vector.elements(els, false)
@@ -1273,8 +1253,7 @@
     case v
     when Vector
       Vector.Raise ErrDimensionMismatch if size != v.size
-      els = collect2(v) {
-        |v1, v2|
+      els = collect2(v) {|v1, v2|
         v1 - v2
       }
       Vector.elements(els, false)
@@ -1298,8 +1277,7 @@
     Vector.Raise ErrDimensionMismatch if size != v.size
     
     p = 0
-    each2(v) {
-      |v1, v2|
+    each2(v) {|v1, v2|
       p += v1 * v2
     }
     p
@@ -1309,8 +1287,7 @@
   # Like Array#collect.
   #
   def collect # :yield: e
-    els = @elements.collect {
-      |v|
+    els = @elements.collect {|v|
       yield v
     }
     Vector.elements(els, false)
@@ -1321,8 +1298,7 @@
   # Like Vector#collect2, but returns a Vector instead of an Array.
   #
   def map2(v) # :yield: e1, e2
-    els = collect2(v) {
-      |v1, v2|
+    els = collect2(v) {|v1, v2|
       yield v1, v2
     }
     Vector.elements(els, false)
Index: ruby_1_9_1/lib/racc/parser.rb
===================================================================
--- ruby_1_9_1/lib/racc/parser.rb	(revision 20879)
+++ ruby_1_9_1/lib/racc/parser.rb	(revision 20880)
@@ -159,7 +159,6 @@
       reduce_n,     use_result,   * = arg
 
       _racc_init_sysvars
-      tok = nil
       act = nil
       i = nil
       nerr = 0
@@ -189,7 +188,7 @@
             ;
           end
 
-          while not (i = action_pointer[@racc_state[-1]]) or
+          while not(i = action_pointer[@racc_state[-1]]) or
                 not @racc_read_next or
                 @racc_t == 0   # $
             unless i and i += @racc_t and

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

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