ruby-changes:17715
From: marcandre <ko1@a...>
Date: Tue, 9 Nov 2010 05:59:19 +0900 (JST)
Subject: [ruby-changes:17715] Ruby:r29726 (trunk): * lib/*.rb: Remove unused variable warnings.
marcandre 2010-11-09 05:59:01 +0900 (Tue, 09 Nov 2010) New Revision: 29726 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29726 Log: * lib/*.rb: Remove unused variable warnings. Patch by Run Paint [ruby-core:30991] Modified files: trunk/ChangeLog trunk/lib/benchmark.rb trunk/lib/drb/ssl.rb trunk/lib/drb/timeridconv.rb trunk/lib/drb/unix.rb trunk/lib/irb/ext/multi-irb.rb trunk/lib/irb/ws-for-case-2.rb trunk/lib/net/ftp.rb trunk/lib/net/http.rb trunk/lib/net/imap.rb trunk/lib/racc/parser.rb trunk/lib/rexml/attribute.rb trunk/lib/rexml/child.rb trunk/lib/rexml/doctype.rb trunk/lib/rexml/element.rb trunk/lib/rexml/formatters/transitive.rb trunk/lib/rexml/functions.rb trunk/lib/rexml/parsers/sax2parser.rb trunk/lib/rexml/parsers/xpathparser.rb trunk/lib/rexml/quickpath.rb trunk/lib/rexml/validation/validation.rb trunk/lib/rexml/xpath_parser.rb trunk/lib/rinda/ring.rb trunk/lib/rss/atom.rb trunk/lib/rss/maker/0.9.rb trunk/lib/rss/maker/1.0.rb trunk/lib/rss/maker/dublincore.rb trunk/lib/rss/rss.rb trunk/lib/shell/system-command.rb trunk/lib/sync.rb trunk/lib/webrick/cgi.rb trunk/lib/webrick/httpresponse.rb trunk/lib/webrick/httpservlet/cgi_runner.rb trunk/lib/webrick/httpservlet/erbhandler.rb trunk/lib/webrick/log.rb trunk/lib/xmlrpc/httpserver.rb trunk/lib/xmlrpc/parser.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 29725) +++ ChangeLog (revision 29726) @@ -1,3 +1,10 @@ +Tue Nov 9 05:54:57 2010 Marc-Andre Lafortune <ruby-core@m...> + + * lib/*.rb: Remove unused variable warnings. + Patch by Run Paint [ruby-core:30991] + + * lib/rubygems/*, lib/rdoc/*.rb, lib/rake/*.rb: ditto + Mon Nov 8 18:26:03 2010 NARUSE, Yui <naruse@r...> * util.c (ruby_hdtoa): fix type cast and bufsize. Index: lib/xmlrpc/httpserver.rb =================================================================== --- lib/xmlrpc/httpserver.rb (revision 29725) +++ lib/xmlrpc/httpserver.rb (revision 29726) @@ -170,7 +170,7 @@ io << http_resp(response.status, response.status_message, response.header, response.body) - rescue Exception => e + rescue Exception io << http_resp(500, "Internal Server Error") end Index: lib/xmlrpc/parser.rb =================================================================== --- lib/xmlrpc/parser.rb (revision 29725) +++ lib/xmlrpc/parser.rb (revision 29726) @@ -714,7 +714,7 @@ end def parse(str) - parser = REXML::Document.parse_stream(str, self) + REXML::Document.parse_stream(str, self) end end Index: lib/webrick/log.rb =================================================================== --- lib/webrick/log.rb (revision 29725) +++ lib/webrick/log.rb (revision 29726) @@ -60,7 +60,7 @@ private def format(arg) - str = if arg.is_a?(Exception) + if arg.is_a?(Exception) "#{arg.class}: #{arg.message}\n\t" << arg.backtrace.join("\n\t") << "\n" elsif arg.respond_to?(:to_str) Index: lib/webrick/httpservlet/erbhandler.rb =================================================================== --- lib/webrick/httpservlet/erbhandler.rb (revision 29725) +++ lib/webrick/httpservlet/erbhandler.rb (revision 29726) @@ -44,8 +44,8 @@ private def evaluate(erb, servlet_request, servlet_response) Module.new.module_eval{ - meta_vars = servlet_request.meta_vars - query = servlet_request.query + servlet_request.meta_vars + servlet_request.query erb.result(binding) } end Index: lib/webrick/httpservlet/cgi_runner.rb =================================================================== --- lib/webrick/httpservlet/cgi_runner.rb (revision 29725) +++ lib/webrick/httpservlet/cgi_runner.rb (revision 29726) @@ -20,7 +20,6 @@ STDIN.binmode -buf = "" len = sysread(STDIN, 8).to_i out = sysread(STDIN, len) STDOUT.reopen(open(out, "w")) @@ -38,7 +37,7 @@ dir = File::dirname(ENV["SCRIPT_FILENAME"]) Dir::chdir dir -if interpreter = ARGV[0] +if ARGV[0] argv = ARGV.dup argv << ENV["SCRIPT_FILENAME"] exec(*argv) Index: lib/webrick/httpresponse.rb =================================================================== --- lib/webrick/httpresponse.rb (revision 29725) +++ lib/webrick/httpresponse.rb (revision 29726) @@ -280,7 +280,7 @@ if @request_method == "HEAD" # do nothing elsif chunked? - remain = body ? @body.bytesize : 0 + body ? @body.bytesize : 0 while buf = @body[@sent_size, @buffer_size] break if buf.empty? data = "" Index: lib/webrick/cgi.rb =================================================================== --- lib/webrick/cgi.rb (revision 29725) +++ lib/webrick/cgi.rb (revision 29726) @@ -143,7 +143,7 @@ setup_header @header_part << CRLF @header_part.rewind - rescue Exception => ex + rescue Exception raise CGIError, "invalid CGI environment" end end Index: lib/rexml/parsers/xpathparser.rb =================================================================== --- lib/rexml/parsers/xpathparser.rb (revision 29725) +++ lib/rexml/parsers/xpathparser.rb (revision 29726) @@ -282,7 +282,6 @@ PI = /^processing-instruction\(/ def NodeTest path, parsed #puts "NodeTest with #{path}" - res = nil case path when /^\*/ path = $' @@ -578,7 +577,6 @@ NUMBER = /^(\d*\.?\d+)/ NT = /^comment|text|processing-instruction|node$/ def PrimaryExpr path, parsed - arry = [] case path when VARIABLE_REFERENCE varname = $1 Index: lib/rexml/parsers/sax2parser.rb =================================================================== --- lib/rexml/parsers/sax2parser.rb (revision 29725) +++ lib/rexml/parsers/sax2parser.rb (revision 29726) @@ -87,7 +87,7 @@ @listeners.each { |sym,match,block| block.start_document if sym == :start_document or sym.nil? } - root = context = [] + context = [] while true event = @parser.pull case event[0] Index: lib/rexml/child.rb =================================================================== --- lib/rexml/child.rb (revision 29725) +++ lib/rexml/child.rb (revision 29726) @@ -88,7 +88,7 @@ # This doesn't yet handle encodings def bytes - encoding = document.encoding + document.encoding to_s end Index: lib/rexml/validation/validation.rb =================================================================== --- lib/rexml/validation/validation.rb (revision 29725) +++ lib/rexml/validation/validation.rb (revision 29726) @@ -33,7 +33,7 @@ sattr = [:start_attribute, nil] eattr = [:end_attribute] text = [:text, nil] - k,v = event[2].find { |key,value| + k, = event[2].find { |key,value| sattr[1] = key #puts "Looking for #{sattr.inspect}" m = @current.next( sattr ) Index: lib/rexml/quickpath.rb =================================================================== --- lib/rexml/quickpath.rb (revision 29725) +++ lib/rexml/quickpath.rb (revision 29726) @@ -33,7 +33,6 @@ results = filter(element.to_a, path) when /^[\[!\w:]/u # match on child - matches = [] children = element.to_a results = filter(children, path) else @@ -51,8 +50,6 @@ when /^\/\//u # Descendant return axe( elements, "descendant-or-self", $' ) when /^\/?\b(\w[-\w]*)\b::/u # Axe - axe_name = $1 - rest = $' return axe( elements, $1, $' ) when /^\/(?=\b([:!\w][-\.\w]*:)?[-!\*\.\w]*\b([^:(]|$)|\*)/u # Child rest = $' Index: lib/rexml/element.rb =================================================================== --- lib/rexml/element.rb (revision 29725) +++ lib/rexml/element.rb (revision 29726) @@ -874,7 +874,6 @@ # a.elements.add(Element.new('b')) #-> <a><b/></a> # a.elements.add('c') #-> <a><b/><c/></a> def add element=nil - rv = nil if element.nil? Element.new("", self, @element.context) elsif not element.kind_of?(Element) @@ -1092,7 +1091,7 @@ delete attr return end - element_document = @element.document + unless value.kind_of? Attribute if @element.document and @element.document.doctype value = Text::normalize( value, @element.document.doctype ) @@ -1197,7 +1196,7 @@ return @element else # the supplied attribute is a top-level one attr = old - res = super(name) + super(name) end @element end Index: lib/rexml/attribute.rb =================================================================== --- lib/rexml/attribute.rb (revision 29725) +++ lib/rexml/attribute.rb (revision 29726) @@ -115,7 +115,7 @@ def doctype if @element doc = @element.document - doctype = doc.doctype if doc + doc.doctype if doc end end Index: lib/rexml/doctype.rb =================================================================== --- lib/rexml/doctype.rb (revision 29725) +++ lib/rexml/doctype.rb (revision 29726) @@ -115,7 +115,6 @@ output << " #{@long_name.inspect}" if @long_name output << " #{@uri.inspect}" if @uri unless @children.empty? - next_indent = indent + 1 output << ' [' @children.each { |child| output << "\n" Index: lib/rexml/functions.rb =================================================================== --- lib/rexml/functions.rb (revision 29725) +++ lib/rexml/functions.rb (revision 29726) @@ -170,7 +170,6 @@ # Kouhei fixed this too def Functions::substring_after( string, test ) ruby_string = string(string) - test_string = string(test) return $1 if ruby_string =~ /#{test}(.*)/ "" end Index: lib/rexml/formatters/transitive.rb =================================================================== --- lib/rexml/formatters/transitive.rb (revision 29725) +++ lib/rexml/formatters/transitive.rb (revision 29726) @@ -37,7 +37,6 @@ # If compact and all children are text, and if the formatted output # is less than the specified width, then try to print everything on # one line - skip = false @level += @indentation node.children.each { |child| write( child, output ) Index: lib/rexml/xpath_parser.rb =================================================================== --- lib/rexml/xpath_parser.rb (revision 29725) +++ lib/rexml/xpath_parser.rb (revision 29726) @@ -687,7 +687,7 @@ return rv else res = [] - enum = SyncEnumerator.new( set1, set2 ).each { |i1, i2| + SyncEnumerator.new( set1, set2 ).each { |i1, i2| #puts "i1 = #{i1.inspect} (#{i1.class.name})" #puts "i2 = #{i2.inspect} (#{i2.class.name})" i1 = norm( i1 ) Index: lib/benchmark.rb =================================================================== --- lib/benchmark.rb (revision 29725) +++ lib/benchmark.rb (revision 29726) @@ -558,16 +558,16 @@ n = ARGV[0].to_i.nonzero? || 50000 puts %Q([#{n} times iterations of `a = "1"']) benchmark(" " + CAPTION, 7, FMTSTR) do |x| - x.report("for:") {for i in 1..n; a = "1"; end} # Benchmark::measure - x.report("times:") {n.times do ; a = "1"; end} - x.report("upto:") {1.upto(n) do ; a = "1"; end} + x.report("for:") {for _ in 1..n; _ = "1"; end} # Benchmark::measure + x.report("times:") {n.times do ; _ = "1"; end} + x.report("upto:") {1.upto(n) do ; _ = "1"; end} end benchmark do [ - measure{for i in 1..n; a = "1"; end}, # Benchmark::measure - measure{n.times do ; a = "1"; end}, - measure{1.upto(n) do ; a = "1"; end} + measure{for _ in 1..n; _ = "1"; end}, # Benchmark::measure + measure{n.times do ; _ = "1"; end}, + measure{1.upto(n) do ; _ = "1"; end} ] end end Index: lib/rss/maker/1.0.rb =================================================================== --- lib/rss/maker/1.0.rb (revision 29725) +++ lib/rss/maker/1.0.rb (revision 29726) @@ -32,7 +32,7 @@ _not_set_required_variables = not_set_required_variables if _not_set_required_variables.empty? channel = RDF::Channel.new(@about) - set = setup_values(channel) + setup_values(channel) channel.dc_dates.clear rss.channel = channel set_parent(channel, rss) Index: lib/rss/maker/0.9.rb =================================================================== --- lib/rss/maker/0.9.rb (revision 29725) +++ lib/rss/maker/0.9.rb (revision 29726) @@ -24,7 +24,7 @@ class Channel < ChannelBase def to_feed(rss) channel = Rss::Channel.new - set = setup_values(channel) + setup_values(channel) _not_set_required_variables = not_set_required_variables if _not_set_required_variables.empty? rss.channel = channel @@ -257,7 +257,7 @@ class Item < ItemBase def to_feed(rss) item = Rss::Channel::Item.new - set = setup_values(item) + setup_values(item) _not_set_required_variables = not_set_required_variables if _not_set_required_variables.empty? rss.items << item Index: lib/rss/maker/dublincore.rb =================================================================== --- lib/rss/maker/dublincore.rb (revision 29725) +++ lib/rss/maker/dublincore.rb (revision 29726) @@ -11,10 +11,7 @@ plural_name ||= "#{name}s" full_name = "#{RSS::DC_PREFIX}_#{name}" full_plural_name = "#{RSS::DC_PREFIX}_#{plural_name}" - klass_name = Utils.to_class_name(name) plural_klass_name = "DublinCore#{Utils.to_class_name(plural_name)}" - full_plural_klass_name = "self.class::#{plural_klass_name}" - full_klass_name = "#{full_plural_klass_name}::#{klass_name}" klass.def_classed_elements(full_name, "value", plural_klass_name, full_plural_name, name) klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1) Index: lib/rss/atom.rb =================================================================== --- lib/rss/atom.rb (revision 29725) +++ lib/rss/atom.rb (revision 29726) @@ -527,7 +527,7 @@ return false unless inline_other? return false if inline_other_xml? - media_type, subtype = mime_split + media_type, = mime_split return true if "text" == media_type.downcase false end Index: lib/rss/rss.rb =================================================================== --- lib/rss/rss.rb (revision 29725) +++ lib/rss/rss.rb (revision 29726) @@ -1093,9 +1093,8 @@ tags = tags.sort_by {|x| element_names.index(x) || tags_size} end - _tags = tags.dup if tags models.each_with_index do |model, i| - name, model_uri, occurs, getter = model + name, _, occurs, = model if DEBUG p "before" Index: lib/irb/ws-for-case-2.rb =================================================================== --- lib/irb/ws-for-case-2.rb (revision 29725) +++ lib/irb/ws-for-case-2.rb (revision 29726) @@ -10,5 +10,5 @@ # while true - IRB::BINDING_QUEUE.push b = binding + IRB::BINDING_QUEUE.push _ = binding end Index: lib/irb/ext/multi-irb.rb =================================================================== --- lib/irb/ext/multi-irb.rb (revision 29725) +++ lib/irb/ext/multi-irb.rb (revision 29726) @@ -29,12 +29,12 @@ end def thread(key) - th, irb = search(key) + th, = search(key) th end def irb(key) - th, irb = search(key) + _, irb = search(key) irb end @@ -62,7 +62,7 @@ def kill(*keys) for key in keys - th, irb = search(key) + th, _ = search(key) IRB.fail IrbAlreadyDead unless th.alive? th.exit end Index: lib/shell/system-command.rb =================================================================== --- lib/shell/system-command.rb (revision 29725) +++ lib/shell/system-command.rb (revision 29726) @@ -84,7 +84,7 @@ notify "Job(%id) start imp-pipe.", @shell.debug? rs = @shell.record_separator unless rs _eop = true - th = Thread.start { + Thread.start { begin while l = @pipe_in.gets @input_queue.push l @@ -109,7 +109,7 @@ def start_export notify "job(%id) start exp-pipe.", @shell.debug? _eop = true - th = Thread.start{ + Thread.start{ begin @input.each do |l| ProcessController::block_output_synchronize do Index: lib/net/http.rb =================================================================== --- lib/net/http.rb (revision 29725) +++ lib/net/http.rb (revision 29726) @@ -1563,7 +1563,7 @@ # or sub-type is not given (e.g. "Content-Type: text"). def sub_type return nil unless @header['content-type'] - main, sub = *self['Content-Type'].split(';').first.to_s.split('/') + _, sub = *self['Content-Type'].split(';').first.to_s.split('/') return nil unless sub sub.strip end Index: lib/net/imap.rb =================================================================== --- lib/net/imap.rb (revision 29725) +++ lib/net/imap.rb (revision 29726) @@ -2680,7 +2680,6 @@ token = match(T_ATOM) name = token.value.upcase match(T_SPACE) - mailbox = astring data = [] token = lookahead if token.symbol == T_SPACE Index: lib/net/ftp.rb =================================================================== --- lib/net/ftp.rb (revision 29725) +++ lib/net/ftp.rb (revision 29726) @@ -322,7 +322,7 @@ sock = TCPServer.open(@sock.addr[3], 0) port = sock.addr[1] host = sock.addr[3] - resp = sendport(host, port) + sendport(host, port) return sock end private :makeport Index: lib/rinda/ring.rb =================================================================== --- lib/rinda/ring.rb (revision 29725) +++ lib/rinda/ring.rb (revision 29726) @@ -198,7 +198,7 @@ def lookup_ring_any(timeout=5) queue = Queue.new - th = Thread.new do + Thread.new do self.lookup_ring(timeout) do |ts| queue.push(ts) end @@ -252,7 +252,7 @@ when 's' require 'rinda/tuplespace' ts = Rinda::TupleSpace.new - place = Rinda::RingServer.new(ts) + Rinda::RingServer.new(ts) $stdin.gets when 'w' finger = Rinda::RingFinger.new(nil) Index: lib/drb/ssl.rb =================================================================== --- lib/drb/ssl.rb (revision 29725) +++ lib/drb/ssl.rb (revision 29726) @@ -122,7 +122,7 @@ end def self.open(uri, config) - host, port, option = parse_uri(uri) + host, port, = parse_uri(uri) host.untaint port.untaint soc = TCPSocket.open(host, port) @@ -134,7 +134,7 @@ def self.open_server(uri, config) uri = 'drbssl://:0' unless uri - host, port, opt = parse_uri(uri) + host, port, = parse_uri(uri) if host.size == 0 host = getservername soc = open_server_inaddr_any(host, port) Index: lib/drb/timeridconv.rb =================================================================== --- lib/drb/timeridconv.rb (revision 29725) +++ lib/drb/timeridconv.rb (revision 29726) @@ -64,7 +64,7 @@ def keeper Thread.new do loop do - size = alternate + alternate sleep(@timeout) end end Index: lib/drb/unix.rb =================================================================== --- lib/drb/unix.rb (revision 29725) +++ lib/drb/unix.rb (revision 29726) @@ -19,14 +19,14 @@ end def self.open(uri, config) - filename, option = parse_uri(uri) + filename, = parse_uri(uri) filename.untaint soc = UNIXSocket.open(filename) self.new(uri, soc, config) end def self.open_server(uri, config) - filename, option = parse_uri(uri) + filename, = parse_uri(uri) if filename.size == 0 soc = temp_server filename = soc.path Index: lib/racc/parser.rb =================================================================== --- lib/racc/parser.rb (revision 29725) +++ lib/racc/parser.rb (revision 29726) @@ -105,13 +105,12 @@ def _racc_do_parse_rb(arg, in_debug) action_table, action_check, action_default, action_pointer, - goto_table, goto_check, goto_default, goto_pointer, - nt_base, reduce_table, token_table, shift_n, - reduce_n, use_result, * = arg + _, _, _, _, + _, _, token_table, _, + _, _, * = arg _racc_init_sysvars tok = act = i = nil - nerr = 0 catch(:racc_end_parse) { while true @@ -154,14 +153,13 @@ def _racc_yyparse_rb(recv, mid, arg, c_debug) action_table, action_check, action_default, action_pointer, - goto_table, goto_check, goto_default, goto_pointer, - nt_base, reduce_table, token_table, shift_n, - reduce_n, use_result, * = arg + _, _, _, _, + _, _, token_table, _, + _, _, * = arg _racc_init_sysvars act = nil i = nil - nerr = 0 catch(:racc_end_parse) { until i = action_pointer[@racc_state[-1]] @@ -210,10 +208,10 @@ ### def _racc_evalact(act, arg) - action_table, action_check, action_default, action_pointer, - goto_table, goto_check, goto_default, goto_pointer, - nt_base, reduce_table, token_table, shift_n, - reduce_n, use_result, * = arg + action_table, action_check, _, action_pointer, + _, _, _, _, + _, _, _, shift_n, reduce_n, + _, _, * = arg nerr = 0 # tmp if act > 0 and act < shift_n @@ -305,10 +303,10 @@ end def _racc_do_reduce(arg, act) - action_table, action_check, action_default, action_pointer, + _, _, _, _, goto_table, goto_check, goto_default, goto_pointer, - nt_base, reduce_table, token_table, shift_n, - reduce_n, use_result, * = arg + nt_base, reduce_table, _, _, + _, use_result, * = arg state = @racc_state vstack = @racc_vstack tstack = @racc_tstack Index: lib/sync.rb =================================================================== --- lib/sync.rb (revision 29725) +++ lib/sync.rb (revision 29726) @@ -128,9 +128,8 @@ def sync_try_lock(mode = EX) return unlock if mode == UN @sync_mutex.synchronize do - ret = sync_try_lock_sub(mode) + sync_try_lock_sub(mode) end - ret end def sync_lock(m = EX) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/