* ext/pathname/lib/pathname.rb, ext/tk/lib/multi-tk.rb,
ext/tk/sample/demos-en/widget, lib/benchmark.rb, lib/irb/cmd/fork.rb, lib/mkmf.rb, lib/net/ftp.rb, lib/net/smtp.rb, lib/open3.rb, lib/pstore.rb, lib/rexml/element.rb, lib/rexml/light/node.rb, lib/rinda/tuplespace.rb, lib/rss/maker/base.rb, lib/rss/maker/entry.rb, lib/scanf.rb, lib/set.rb, lib/shell.rb, lib/shell/command-processor.rb, lib/shell/process-controller.rb, lib/shell/system-command.rb, lib/uri/common.rb: remove unused block arguments to avoid creating Proc objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0e68c46e2d
commit
c3749b6a6d
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
Sat Nov 5 16:27:52 2011 Kazuki Tsujimoto <kazuki@callcc.net>
|
||||||
|
|
||||||
|
* ext/pathname/lib/pathname.rb, ext/tk/lib/multi-tk.rb,
|
||||||
|
ext/tk/sample/demos-en/widget, lib/benchmark.rb, lib/irb/cmd/fork.rb,
|
||||||
|
lib/mkmf.rb, lib/net/ftp.rb, lib/net/smtp.rb, lib/open3.rb,
|
||||||
|
lib/pstore.rb, lib/rexml/element.rb, lib/rexml/light/node.rb,
|
||||||
|
lib/rinda/tuplespace.rb, lib/rss/maker/base.rb,
|
||||||
|
lib/rss/maker/entry.rb, lib/scanf.rb, lib/set.rb, lib/shell.rb,
|
||||||
|
lib/shell/command-processor.rb, lib/shell/process-controller.rb,
|
||||||
|
lib/shell/system-command.rb, lib/uri/common.rb: remove unused block
|
||||||
|
arguments to avoid creating Proc objects.
|
||||||
|
|
||||||
Sat Nov 5 15:45:04 2011 Tanaka Akira <akr@fsij.org>
|
Sat Nov 5 15:45:04 2011 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/socket/init.c (rsock_socket0): extract single socket() call with
|
* ext/socket/init.c (rsock_socket0): extract single socket() call with
|
||||||
|
@ -495,7 +495,7 @@ class Pathname # * Find *
|
|||||||
# If +self+ is <tt>.</tt>, yielded pathnames begin with a filename in the
|
# If +self+ is <tt>.</tt>, yielded pathnames begin with a filename in the
|
||||||
# current directory, not <tt>./</tt>.
|
# current directory, not <tt>./</tt>.
|
||||||
#
|
#
|
||||||
def find(&block) # :yield: pathname
|
def find # :yield: pathname
|
||||||
require 'find'
|
require 'find'
|
||||||
if @path == '.'
|
if @path == '.'
|
||||||
Find.find(@path) {|f| yield self.class.new(f.sub(%r{\A\./}, '')) }
|
Find.find(@path) {|f| yield self.class.new(f.sub(%r{\A\./}, '')) }
|
||||||
|
@ -2103,7 +2103,7 @@ end
|
|||||||
# evaluate a procedure on the proper interpreter
|
# evaluate a procedure on the proper interpreter
|
||||||
class MultiTkIp
|
class MultiTkIp
|
||||||
# instance & class method
|
# instance & class method
|
||||||
def _proc_on_safelevel(cmd=nil, &blk) # require a block for eval
|
def _proc_on_safelevel(cmd=nil) # require a block for eval
|
||||||
if cmd
|
if cmd
|
||||||
if cmd.kind_of?(Method)
|
if cmd.kind_of?(Method)
|
||||||
_proc_on_safelevel{|*args| cmd.call(*args)}
|
_proc_on_safelevel{|*args| cmd.call(*args)}
|
||||||
|
@ -627,7 +627,7 @@ class Object
|
|||||||
end
|
end
|
||||||
|
|
||||||
class Proc
|
class Proc
|
||||||
def initialize(*args, &b)
|
def initialize(*args)
|
||||||
super
|
super
|
||||||
@__pseudo_toplevel__ = Thread.current[:TOPLEVEL]
|
@__pseudo_toplevel__ = Thread.current[:TOPLEVEL]
|
||||||
end
|
end
|
||||||
|
@ -243,7 +243,7 @@ module Benchmark
|
|||||||
# #bmbm yields a Benchmark::Job object and returns an array of
|
# #bmbm yields a Benchmark::Job object and returns an array of
|
||||||
# Benchmark::Tms objects.
|
# Benchmark::Tms objects.
|
||||||
#
|
#
|
||||||
def bmbm(width = 0, &blk) # :yield: job
|
def bmbm(width = 0) # :yield: job
|
||||||
job = Job.new(width)
|
job = Job.new(width)
|
||||||
yield(job)
|
yield(job)
|
||||||
width = job.width + 1
|
width = job.width + 1
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
module IRB
|
module IRB
|
||||||
module ExtendCommand
|
module ExtendCommand
|
||||||
class Fork<Nop
|
class Fork<Nop
|
||||||
def execute(&block)
|
def execute
|
||||||
pid = send ExtendCommand.irb_original_method_name("fork")
|
pid = send ExtendCommand.irb_original_method_name("fork")
|
||||||
unless pid
|
unless pid
|
||||||
class << self
|
class << self
|
||||||
|
@ -1125,7 +1125,7 @@ def typedef_expr(type, headers)
|
|||||||
return "rbcv_typedef_", member, prelude
|
return "rbcv_typedef_", member, prelude
|
||||||
end
|
end
|
||||||
|
|
||||||
def try_signedness(type, member, headers = nil, opts = nil, &b)
|
def try_signedness(type, member, headers = nil, opts = nil)
|
||||||
raise ArgumentError, "don't know how to tell signedness of members" if member
|
raise ArgumentError, "don't know how to tell signedness of members" if member
|
||||||
if try_static_assert("(#{type})-1 < 0", headers, opts)
|
if try_static_assert("(#{type})-1 < 0", headers, opts)
|
||||||
return -1
|
return -1
|
||||||
|
@ -493,7 +493,7 @@ module Net
|
|||||||
# +file+ to the server. If the optional block is given, it also passes it
|
# +file+ to the server. If the optional block is given, it also passes it
|
||||||
# the data, in chunks of +blocksize+ characters.
|
# the data, in chunks of +blocksize+ characters.
|
||||||
#
|
#
|
||||||
def storbinary(cmd, file, blocksize, rest_offset = nil, &block) # :yield: data
|
def storbinary(cmd, file, blocksize, rest_offset = nil) # :yield: data
|
||||||
if rest_offset
|
if rest_offset
|
||||||
file.seek(rest_offset, IO::SEEK_SET)
|
file.seek(rest_offset, IO::SEEK_SET)
|
||||||
end
|
end
|
||||||
@ -504,7 +504,7 @@ module Net
|
|||||||
buf = file.read(blocksize)
|
buf = file.read(blocksize)
|
||||||
break if buf == nil
|
break if buf == nil
|
||||||
conn.write(buf)
|
conn.write(buf)
|
||||||
yield(buf) if block
|
yield(buf) if block_given?
|
||||||
end
|
end
|
||||||
conn.close
|
conn.close
|
||||||
voidresp
|
voidresp
|
||||||
@ -525,7 +525,7 @@ module Net
|
|||||||
# named +file+ to the server, one line at a time. If the optional block is
|
# named +file+ to the server, one line at a time. If the optional block is
|
||||||
# given, it also passes it the lines.
|
# given, it also passes it the lines.
|
||||||
#
|
#
|
||||||
def storlines(cmd, file, &block) # :yield: line
|
def storlines(cmd, file) # :yield: line
|
||||||
synchronize do
|
synchronize do
|
||||||
with_binary(false) do
|
with_binary(false) do
|
||||||
conn = transfercmd(cmd)
|
conn = transfercmd(cmd)
|
||||||
@ -536,7 +536,7 @@ module Net
|
|||||||
buf = buf.chomp + CRLF
|
buf = buf.chomp + CRLF
|
||||||
end
|
end
|
||||||
conn.write(buf)
|
conn.write(buf)
|
||||||
yield(buf) if block
|
yield(buf) if block_given?
|
||||||
end
|
end
|
||||||
conn.close
|
conn.close
|
||||||
voidresp
|
voidresp
|
||||||
|
@ -933,7 +933,7 @@ module Net
|
|||||||
Response.parse(buf)
|
Response.parse(buf)
|
||||||
end
|
end
|
||||||
|
|
||||||
def critical(&block)
|
def critical
|
||||||
return '200 dummy reply code' if @error_occured
|
return '200 dummy reply code' if @error_occured
|
||||||
begin
|
begin
|
||||||
return yield()
|
return yield()
|
||||||
|
@ -266,7 +266,7 @@ module Open3
|
|||||||
# STDOUT.binmode; print thumnail
|
# STDOUT.binmode; print thumnail
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
def capture3(*cmd, &block)
|
def capture3(*cmd)
|
||||||
if Hash === cmd.last
|
if Hash === cmd.last
|
||||||
opts = cmd.pop.dup
|
opts = cmd.pop.dup
|
||||||
else
|
else
|
||||||
@ -320,7 +320,7 @@ module Open3
|
|||||||
# End
|
# End
|
||||||
# image, s = Open3.capture2("gnuplot", :stdin_data=>gnuplot_commands, :binmode=>true)
|
# image, s = Open3.capture2("gnuplot", :stdin_data=>gnuplot_commands, :binmode=>true)
|
||||||
#
|
#
|
||||||
def capture2(*cmd, &block)
|
def capture2(*cmd)
|
||||||
if Hash === cmd.last
|
if Hash === cmd.last
|
||||||
opts = cmd.pop.dup
|
opts = cmd.pop.dup
|
||||||
else
|
else
|
||||||
@ -359,7 +359,7 @@ module Open3
|
|||||||
# # capture make log
|
# # capture make log
|
||||||
# make_log, s = Open3.capture2e("make")
|
# make_log, s = Open3.capture2e("make")
|
||||||
#
|
#
|
||||||
def capture2e(*cmd, &block)
|
def capture2e(*cmd)
|
||||||
if Hash === cmd.last
|
if Hash === cmd.last
|
||||||
opts = cmd.pop.dup
|
opts = cmd.pop.dup
|
||||||
else
|
else
|
||||||
@ -662,7 +662,7 @@ module Open3
|
|||||||
end
|
end
|
||||||
module_function :pipeline
|
module_function :pipeline
|
||||||
|
|
||||||
def pipeline_run(cmds, pipeline_opts, child_io, parent_io, &block) # :nodoc:
|
def pipeline_run(cmds, pipeline_opts, child_io, parent_io) # :nodoc:
|
||||||
if cmds.empty?
|
if cmds.empty?
|
||||||
raise ArgumentError, "no commands"
|
raise ArgumentError, "no commands"
|
||||||
end
|
end
|
||||||
|
@ -310,7 +310,7 @@ class PStore
|
|||||||
#
|
#
|
||||||
# Note that PStore does not support nested transactions.
|
# Note that PStore does not support nested transactions.
|
||||||
#
|
#
|
||||||
def transaction(read_only = false, &block) # :yields: pstore
|
def transaction(read_only = false) # :yields: pstore
|
||||||
value = nil
|
value = nil
|
||||||
raise PStore::Error, "nested transaction" if !@thread_safe && @lock.locked?
|
raise PStore::Error, "nested transaction" if !@thread_safe && @lock.locked?
|
||||||
@lock.synchronize do
|
@lock.synchronize do
|
||||||
|
@ -901,11 +901,11 @@ module REXML
|
|||||||
# #-> Yields <b/>, <c/>, <d/>, <b/>, <c/>, <d/>
|
# #-> Yields <b/>, <c/>, <d/>, <b/>, <c/>, <d/>
|
||||||
# XPath.each(doc.root, 'child::node()', &block)
|
# XPath.each(doc.root, 'child::node()', &block)
|
||||||
# #-> Yields <b/>, <c/>, <d/>, sean, <b/>, <c/>, <d/>
|
# #-> Yields <b/>, <c/>, <d/>, sean, <b/>, <c/>, <d/>
|
||||||
def each( xpath=nil, &block)
|
def each( xpath=nil )
|
||||||
XPath::each( @element, xpath ) {|e| yield e if e.kind_of? Element }
|
XPath::each( @element, xpath ) {|e| yield e if e.kind_of? Element }
|
||||||
end
|
end
|
||||||
|
|
||||||
def collect( xpath=nil, &block )
|
def collect( xpath=nil )
|
||||||
collection = []
|
collection = []
|
||||||
XPath::each( @element, xpath ) {|e|
|
XPath::each( @element, xpath ) {|e|
|
||||||
collection << yield(e) if e.kind_of?(Element)
|
collection << yield(e) if e.kind_of?(Element)
|
||||||
@ -913,7 +913,7 @@ module REXML
|
|||||||
collection
|
collection
|
||||||
end
|
end
|
||||||
|
|
||||||
def inject( xpath=nil, initial=nil, &block )
|
def inject( xpath=nil, initial=nil )
|
||||||
first = true
|
first = true
|
||||||
XPath::each( @element, xpath ) {|e|
|
XPath::each( @element, xpath ) {|e|
|
||||||
if (e.kind_of? Element)
|
if (e.kind_of? Element)
|
||||||
|
@ -40,7 +40,7 @@ module REXML
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def each( &block )
|
def each
|
||||||
size.times { |x| yield( at(x+4) ) }
|
size.times { |x| yield( at(x+4) ) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ module Rinda
|
|||||||
@bin.delete_at(idx) if idx
|
@bin.delete_at(idx) if idx
|
||||||
end
|
end
|
||||||
|
|
||||||
def find(&blk)
|
def find
|
||||||
@bin.reverse_each do |x|
|
@bin.reverse_each do |x|
|
||||||
return x if yield(x)
|
return x if yield(x)
|
||||||
end
|
end
|
||||||
|
@ -353,7 +353,7 @@ module RSS
|
|||||||
|
|
||||||
module SetupDefaultDate
|
module SetupDefaultDate
|
||||||
private
|
private
|
||||||
def _set_default_values(&block)
|
def _set_default_values
|
||||||
keep = {
|
keep = {
|
||||||
:date => date,
|
:date => date,
|
||||||
:dc_dates => dc_dates.to_a.dup,
|
:dc_dates => dc_dates.to_a.dup,
|
||||||
@ -365,7 +365,7 @@ module RSS
|
|||||||
dc_dates.unshift(dc_date)
|
dc_dates.unshift(dc_date)
|
||||||
end
|
end
|
||||||
self.date ||= self.dc_date
|
self.date ||= self.dc_date
|
||||||
super(&block)
|
super
|
||||||
ensure
|
ensure
|
||||||
date = keep[:date]
|
date = keep[:date]
|
||||||
dc_dates.replace(keep[:dc_dates])
|
dc_dates.replace(keep[:dc_dates])
|
||||||
@ -379,7 +379,7 @@ module RSS
|
|||||||
|
|
||||||
module SetupDefaultLanguage
|
module SetupDefaultLanguage
|
||||||
private
|
private
|
||||||
def _set_default_values(&block)
|
def _set_default_values
|
||||||
keep = {
|
keep = {
|
||||||
:dc_languages => dc_languages.to_a.dup,
|
:dc_languages => dc_languages.to_a.dup,
|
||||||
}
|
}
|
||||||
@ -390,7 +390,7 @@ module RSS
|
|||||||
dc_language.value = _language.dup
|
dc_language.value = _language.dup
|
||||||
dc_languages.unshift(dc_language)
|
dc_languages.unshift(dc_language)
|
||||||
end
|
end
|
||||||
super(&block)
|
super
|
||||||
ensure
|
ensure
|
||||||
dc_languages.replace(keep[:dc_languages])
|
dc_languages.replace(keep[:dc_languages])
|
||||||
end
|
end
|
||||||
|
@ -99,7 +99,7 @@ module RSS
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def _set_default_values(&block)
|
def _set_default_values
|
||||||
keep = {
|
keep = {
|
||||||
:authors => authors.to_a.dup,
|
:authors => authors.to_a.dup,
|
||||||
:contributors => contributors.to_a.dup,
|
:contributors => contributors.to_a.dup,
|
||||||
@ -126,7 +126,7 @@ module RSS
|
|||||||
@maker.channel.title {|t| @title = t}
|
@maker.channel.title {|t| @title = t}
|
||||||
end
|
end
|
||||||
self.updated ||= @maker.channel.updated
|
self.updated ||= @maker.channel.updated
|
||||||
super(&block)
|
super
|
||||||
ensure
|
ensure
|
||||||
authors.replace(keep[:authors])
|
authors.replace(keep[:authors])
|
||||||
contributors.replace(keep[:contributors])
|
contributors.replace(keep[:contributors])
|
||||||
|
@ -745,7 +745,7 @@ class String
|
|||||||
# See Scanf for details on creating a format string.
|
# See Scanf for details on creating a format string.
|
||||||
#
|
#
|
||||||
# You will need to require 'scanf' to use String#block_scanf
|
# You will need to require 'scanf' to use String#block_scanf
|
||||||
def block_scanf(fstr,&b) #:yield: current_match
|
def block_scanf(fstr) #:yield: current_match
|
||||||
fs = Scanf::FormatString.new(fstr)
|
fs = Scanf::FormatString.new(fstr)
|
||||||
str = self.dup
|
str = self.dup
|
||||||
final = []
|
final = []
|
||||||
|
@ -531,7 +531,7 @@ class SortedSet < Set
|
|||||||
require 'rbtree'
|
require 'rbtree'
|
||||||
|
|
||||||
module_eval %{
|
module_eval %{
|
||||||
def initialize(*args, &block)
|
def initialize(*args)
|
||||||
@hash = RBTree.new
|
@hash = RBTree.new
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
@ -544,7 +544,7 @@ class SortedSet < Set
|
|||||||
}
|
}
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
module_eval %{
|
module_eval %{
|
||||||
def initialize(*args, &block)
|
def initialize(*args)
|
||||||
@keys = nil
|
@keys = nil
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
@ -286,7 +286,7 @@ class Shell
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.notify(*opts, &block)
|
def self.notify(*opts)
|
||||||
Shell::debug_output_synchronize do
|
Shell::debug_output_synchronize do
|
||||||
if opts[-1].kind_of?(String)
|
if opts[-1].kind_of?(String)
|
||||||
yorn = verbose?
|
yorn = verbose?
|
||||||
|
@ -335,7 +335,7 @@ class Shell
|
|||||||
end
|
end
|
||||||
|
|
||||||
# %pwd, %cwd -> @pwd
|
# %pwd, %cwd -> @pwd
|
||||||
def notify(*opts, &block)
|
def notify(*opts)
|
||||||
Shell.notify(*opts) {|mes|
|
Shell.notify(*opts) {|mes|
|
||||||
yield mes if iterator?
|
yield mes if iterator?
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ class Shell
|
|||||||
def self.alias_map
|
def self.alias_map
|
||||||
@alias_map
|
@alias_map
|
||||||
end
|
end
|
||||||
def self.alias_command(ali, command, *opts, &block)
|
def self.alias_command(ali, command, *opts)
|
||||||
ali = ali.id2name if ali.kind_of?(Symbol)
|
ali = ali.id2name if ali.kind_of?(Symbol)
|
||||||
command = command.id2name if command.kind_of?(Symbol)
|
command = command.id2name if command.kind_of?(Symbol)
|
||||||
begin
|
begin
|
||||||
|
@ -234,7 +234,7 @@ class Shell
|
|||||||
end
|
end
|
||||||
|
|
||||||
# simple fork
|
# simple fork
|
||||||
def sfork(command, &block)
|
def sfork(command)
|
||||||
pipe_me_in, pipe_peer_out = IO.pipe
|
pipe_me_in, pipe_peer_out = IO.pipe
|
||||||
pipe_peer_in, pipe_me_out = IO.pipe
|
pipe_peer_in, pipe_me_out = IO.pipe
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ class Shell
|
|||||||
# then
|
# then
|
||||||
# mes: "job(%id) close pipe-out."
|
# mes: "job(%id) close pipe-out."
|
||||||
# yorn: Boolean(@shell.debug? or @shell.verbose?)
|
# yorn: Boolean(@shell.debug? or @shell.verbose?)
|
||||||
def notify(*opts, &block)
|
def notify(*opts)
|
||||||
@shell.notify(*opts) do |mes|
|
@shell.notify(*opts) do |mes|
|
||||||
yield mes if iterator?
|
yield mes if iterator?
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ module URI
|
|||||||
#
|
#
|
||||||
# see also URI::Parser.make_regexp
|
# see also URI::Parser.make_regexp
|
||||||
#
|
#
|
||||||
def extract(str, schemes = nil, &block)
|
def extract(str, schemes = nil)
|
||||||
if block_given?
|
if block_given?
|
||||||
str.scan(make_regexp(schemes)) { yield $& }
|
str.scan(make_regexp(schemes)) { yield $& }
|
||||||
nil
|
nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user