1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

consistent parentheses in assignment RHS.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-10-16 17:47:19 +00:00
parent 3ec0bc3828
commit 8ef5da3be1
26 changed files with 48 additions and 48 deletions

View file

@ -14,7 +14,7 @@ def uname_s
case Config::CONFIG['host_os'] case Config::CONFIG['host_os']
when 'cygwin' when 'cygwin'
require 'Win32API' require 'Win32API'
uname = Win32API.new 'cygwin1', 'uname', 'P', 'I' uname = Win32API.new('cygwin1', 'uname', 'P', 'I')
utsname = ' ' * 100 utsname = ' ' * 100
raise 'cannot get system name' if uname.call(utsname) == -1 raise 'cannot get system name' if uname.call(utsname) == -1

View file

@ -79,7 +79,7 @@ module DL
symty = rty + ty symty = rty + ty
module_eval("module_function :#{func}") module_eval("module_function :#{func}")
sym = module_eval [ sym = module_eval([
"DL::callback(\"#{symty}\"){|*args|", "DL::callback(\"#{symty}\"){|*args|",
" sym,rdec,enc,dec = @SYM['#{func}']", " sym,rdec,enc,dec = @SYM['#{func}']",
" args = enc.call(args) if enc", " args = enc.call(args) if enc",
@ -90,7 +90,7 @@ module DL
" @args = rs", " @args = rs",
" @retval", " @retval",
"}", "}",
].join("\n") ].join("\n"))
@SYM[func] = [sym,rdec,enc,dec] @SYM[func] = [sym,rdec,enc,dec]

View file

@ -39,7 +39,7 @@ module LIBC
def my_compare(ptr1, ptr2) def my_compare(ptr1, ptr2)
ptr1.ptr.to_s <=> ptr2.ptr.to_s ptr1.ptr.to_s <=> ptr2.ptr.to_s
end end
COMPARE = callback "int my_compare(char**, char**)" COMPARE = callback("int my_compare(char**, char**)")
end end

View file

@ -14,7 +14,7 @@ def uname_s
case Config::CONFIG['host_os'] case Config::CONFIG['host_os']
when 'cygwin' when 'cygwin'
require 'Win32API' require 'Win32API'
uname = Win32API.new 'cygwin1', 'uname', 'P', 'I' uname = Win32API.new('cygwin1', 'uname', 'P', 'I')
utsname = ' ' * 100 utsname = ' ' * 100
raise 'cannot get system name' if uname.call(utsname) == -1 raise 'cannot get system name' if uname.call(utsname) == -1

View file

@ -14,7 +14,7 @@ def uname_s
case Config::CONFIG['host_os'] case Config::CONFIG['host_os']
when 'cygwin' when 'cygwin'
require 'Win32API' require 'Win32API'
uname = Win32API.new 'cygwin1', 'uname', 'P', 'I' uname = Win32API.new('cygwin1', 'uname', 'P', 'I')
utsname = ' ' * 100 utsname = ' ' * 100
raise 'cannot get system name' if uname.call(utsname) == -1 raise 'cannot get system name' if uname.call(utsname) == -1

View file

@ -1388,7 +1388,7 @@ module Tk
end end
end end
def group(*args) def group(*args)
w = tk_call 'wm', 'group', path, *args w = tk_call('wm', 'group', path, *args)
if args.size == 0 if args.size == 0
window(w) window(w)
else else
@ -3303,7 +3303,7 @@ module TkOptionDB
proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ proc_str proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ proc_str
proc_str = __closed_block_check__(proc_str) proc_str = __closed_block_check__(proc_str)
proc_str = __check_proc_string__(proc_str) proc_str = __check_proc_string__(proc_str)
res_proc = eval 'Proc.new' + proc_str res_proc = eval('Proc.new' + proc_str)
self::METHOD_TBL[id] = res_proc self::METHOD_TBL[id] = res_proc
end end
proc{ proc{

View file

@ -5651,7 +5651,7 @@ class Microsoft_XMLDOM_1_0 # DOMDocument
@clsid = "{2933BF90-7B36-11D2-B20E-00C04F983E60}" @clsid = "{2933BF90-7B36-11D2-B20E-00C04F983E60}"
@progid = "Microsoft.XMLDOM.1.0" @progid = "Microsoft.XMLDOM.1.0"
if obj.nil? if obj.nil?
@dispatch = WIN32OLE.new @progid @dispatch = WIN32OLE.new(@progid)
else else
@dispatch = obj @dispatch = obj
end end
@ -6258,7 +6258,7 @@ class Microsoft_FreeThreadedXMLDOM_1_0 # DOMFreeThreadedDocument
@clsid = "{2933BF91-7B36-11D2-B20E-00C04F983E60}" @clsid = "{2933BF91-7B36-11D2-B20E-00C04F983E60}"
@progid = "Microsoft.FreeThreadedXMLDOM.1.0" @progid = "Microsoft.FreeThreadedXMLDOM.1.0"
if obj.nil? if obj.nil?
@dispatch = WIN32OLE.new @progid @dispatch = WIN32OLE.new(@progid)
else else
@dispatch = obj @dispatch = obj
end end
@ -6992,7 +6992,7 @@ class Microsoft_XMLHTTP_1 # XMLHTTPRequest
@clsid = "{ED8C108E-4349-11D2-91A4-00C04F7969E8}" @clsid = "{ED8C108E-4349-11D2-91A4-00C04F7969E8}"
@progid = "Microsoft.XMLHTTP.1" @progid = "Microsoft.XMLHTTP.1"
if obj.nil? if obj.nil?
@dispatch = WIN32OLE.new @progid @dispatch = WIN32OLE.new(@progid)
else else
@dispatch = obj @dispatch = obj
end end
@ -7136,7 +7136,7 @@ class Microsoft_XMLDSO_1_0 # XMLDSOControl
@clsid = "{550DDA30-0541-11D2-9CA9-0060B0EC3D39}" @clsid = "{550DDA30-0541-11D2-9CA9-0060B0EC3D39}"
@progid = "Microsoft.XMLDSO.1.0" @progid = "Microsoft.XMLDSO.1.0"
if obj.nil? if obj.nil?
@dispatch = WIN32OLE.new @progid @dispatch = WIN32OLE.new(@progid)
else else
@dispatch = obj @dispatch = obj
end end
@ -7207,7 +7207,7 @@ class Msxml # XMLDocument
@clsid = "{CFC399AF-D876-11D0-9C10-00C04FC99C8E}" @clsid = "{CFC399AF-D876-11D0-9C10-00C04FC99C8E}"
@progid = "Msxml" @progid = "Msxml"
if obj.nil? if obj.nil?
@dispatch = WIN32OLE.new @progid @dispatch = WIN32OLE.new(@progid)
else else
@dispatch = obj @dispatch = obj
end end

View file

@ -2302,8 +2302,8 @@ class CGI
else else
at_exit() do at_exit() do
if defined?(CGI_PARAMS) if defined?(CGI_PARAMS)
self.class.class_eval("remove_const(:CGI_PARAMS)") CGI.class_eval("remove_const(:CGI_PARAMS)")
self.class.class_eval("remove_const(:CGI_COOKIES)") CGI.class_eval("remove_const(:CGI_COOKIES)")
end end
end end
end end

View file

@ -69,7 +69,7 @@ class CGI
unless File::exist? path unless File::exist? path
@hash = {} @hash = {}
end end
@p = ::PStore.new path @p = ::PStore.new(path)
end end
# Restore session state from the session's PStore file. # Restore session state from the session's PStore file.
@ -114,7 +114,7 @@ if $0 == __FILE__
# :enddoc: # :enddoc:
STDIN.reopen("/dev/null") STDIN.reopen("/dev/null")
cgi = CGI.new cgi = CGI.new
session = CGI::Session.new cgi, 'database_manager' => CGI::Session::PStore session = CGI::Session.new(cgi, 'database_manager' => CGI::Session::PStore)
session['key'] = {'k' => 'v'} session['key'] = {'k' => 'v'}
puts session['key'].class puts session['key'].class
fail unless Hash === session['key'] fail unless Hash === session['key']

View file

@ -3,7 +3,7 @@ module IRB
module ExtendCommand module ExtendCommand
class Fork<Nop class Fork<Nop
def execute(&block) def execute(&block)
pid = send ExtendCommand.irb_original_method_name("fork") pid = send(ExtendCommand.irb_original_method_name("fork"))
unless pid unless pid
class<<self class<<self
alias_method :exit, ExtendCommand.irb_original_method_name('exit') alias_method :exit, ExtendCommand.irb_original_method_name('exit')

View file

@ -112,7 +112,7 @@ module IRB
select_message(receiver, message, candidates) select_message(receiver, message, candidates)
when /^(\$[^.]*)$/ when /^(\$[^.]*)$/
candidates = global_variables.grep Regexp.new(Regexp.quote($1)) candidates = global_variables.grep(Regexp.new(Regexp.quote($1)))
# when /^(\$?(\.?[^.]+)+)\.([^.]*)$/ # when /^(\$?(\.?[^.]+)+)\.([^.]*)$/
when /^((\.?[^.]+)+)\.([^.]*)$/ when /^((\.?[^.]+)+)\.([^.]*)$/
@ -120,9 +120,9 @@ module IRB
receiver = $1 receiver = $1
message = Regexp.quote($3) message = Regexp.quote($3)
gv = eval "global_variables", bind gv = eval("global_variables", bind)
lv = eval "local_variables", bind lv = eval("local_variables", bind)
cv = eval "self.class.constants", bind cv = eval("self.class.constants", bind)
if (gv | lv | cv).include?(receiver) if (gv | lv | cv).include?(receiver)
# foo.func and foo is local var. # foo.func and foo is local var.

View file

@ -56,7 +56,7 @@ EOF
end end
end end
if main.empty? if main.empty?
@main = eval "self", @binding @main = eval("self", @binding)
else else
@main = main[0] @main = main[0]
IRB.conf[:__MAIN__] = @main IRB.conf[:__MAIN__] = @main

View file

@ -797,7 +797,7 @@ def create_makefile(target, srcprefix = nil)
deffile = EXPORT_PREFIX + origdef deffile = EXPORT_PREFIX + origdef
unless File.exist? deffile unless File.exist? deffile
if File.exist? File.join(srcdir, deffile) if File.exist? File.join(srcdir, deffile)
deffile = File.join srcdir, deffile deffile = File.join(srcdir, deffile)
elsif !EXPORT_PREFIX.empty? and File.exist?(origdef = File.join(srcdir, origdef)) elsif !EXPORT_PREFIX.empty? and File.exist?(origdef = File.join(srcdir, origdef))
open(origdef) do |d| open(origdef) do |d|
open(deffile, 'wb') do |f| open(deffile, 'wb') do |f|

View file

@ -313,7 +313,7 @@ module Net # :nodoc:
end end
hexvals = line.unpack('H*')[0] hexvals = line.unpack('H*')[0]
hexvals += ' ' * (32 - hexvals.length) hexvals += ' ' * (32 - hexvals.length)
hexvals = format "%s %s %s %s " * 4, *hexvals.unpack('a2' * 16) hexvals = format("%s %s %s %s " * 4, *hexvals.unpack('a2' * 16))
line = line.gsub(/[\000-\037\177-\377]/n, '.') line = line.gsub(/[\000-\037\177-\377]/n, '.')
printf "%s 0x%5.5x: %s%s\n", dir, addr, hexvals, line printf "%s 0x%5.5x: %s%s\n", dir, addr, hexvals, line
addr += 16 addr += 16

View file

@ -1155,7 +1155,7 @@ class Resolv
len, = self.get_unpack('n') len, = self.get_unpack('n')
save_limit = @limit save_limit = @limit
@limit = @index + len @limit = @index + len
d = yield len d = yield(len)
if @index < @limit if @index < @limit
raise DecodeError.new("junk exist") raise DecodeError.new("junk exist")
elsif @limit < @index elsif @limit < @index

View file

@ -48,7 +48,7 @@ module REXML
def EntityDecl.parse_source source, listener def EntityDecl.parse_source source, listener
md = source.match( PATTERN_RE, true ) md = source.match( PATTERN_RE, true )
thing = md[0].squeeze " \t\n\r" thing = md[0].squeeze(" \t\n\r")
listener.send inspect.downcase, thing listener.send inspect.downcase, thing
end end
end end

View file

@ -31,7 +31,7 @@ module REXML
def NotationDecl.parse_source source, listener def NotationDecl.parse_source source, listener
md = source.match( PATTERN_RE, true ) md = source.match( PATTERN_RE, true )
thing = md[0].squeeze " \t\n\r" thing = md[0].squeeze(" \t\n\r")
listener.send inspect.downcase, thing listener.send inspect.downcase, thing
end end
end end

View file

@ -52,8 +52,8 @@ module REXML
def initialize( arg = UNDEFINED, parent=nil, context=nil ) def initialize( arg = UNDEFINED, parent=nil, context=nil )
super(parent) super(parent)
@elements = Elements.new self @elements = Elements.new(self)
@attributes = Attributes.new self @attributes = Attributes.new(self)
@context = context @context = context
if arg.kind_of? String if arg.kind_of? String
@ -253,7 +253,7 @@ module REXML
# el = Element.new 'my-tag' # el = Element.new 'my-tag'
# doc.add_element el # doc.add_element el
def add_element element=nil, attrs=nil def add_element element=nil, attrs=nil
el = @elements.add element el = @elements.add(element)
if attrs.kind_of? Hash if attrs.kind_of? Hash
attrs.each do |key, value| attrs.each do |key, value|
el.attributes[key]=value if key =~ /^xmlns:/ el.attributes[key]=value if key =~ /^xmlns:/
@ -412,7 +412,7 @@ module REXML
# # The element 'p' has two text elements, "some text " and " more text". # # The element 'p' has two text elements, "some text " and " more text".
# doc.root.text #-> "some text " # doc.root.text #-> "some text "
def text( path = nil ) def text( path = nil )
rv = get_text path rv = get_text(path)
return rv.value unless rv.nil? return rv.value unless rv.nil?
nil nil
end end
@ -724,7 +724,7 @@ module REXML
def []( index, name=nil) def []( index, name=nil)
if index.kind_of? Integer if index.kind_of? Integer
raise "index (#{index}) must be >= 1" if index < 1 raise "index (#{index}) must be >= 1" if index < 1
name = literalize name if name name = literalize(name) if name
num = 0 num = 0
child = nil child = nil
@element.find { |child| @element.find { |child|
@ -1016,13 +1016,13 @@ module REXML
# doc.root.attributes['x:foo'] = nil # doc.root.attributes['x:foo'] = nil
def []=( name, value ) def []=( name, value )
if value.nil? # Delete the named attribute if value.nil? # Delete the named attribute
attr = get_attribute name attr = get_attribute(name)
delete attr delete attr
return return
end end
value = Attribute.new(name, value) unless value.kind_of? Attribute value = Attribute.new(name, value) unless value.kind_of? Attribute
value.element = @element value.element = @element
old_attr = fetch value.name, nil old_attr = fetch(value.name, nil)
if old_attr.nil? if old_attr.nil?
store(value.name, value) store(value.name, value)
elsif old_attr.kind_of? Hash elsif old_attr.kind_of? Hash
@ -1104,7 +1104,7 @@ module REXML
prefix, name = $1, $2 prefix, name = $1, $2
prefix = '' unless prefix prefix = '' unless prefix
end end
old = fetch name, nil old = fetch(name, nil)
attr = nil attr = nil
if old.kind_of? Hash # the supplied attribute is one of many if old.kind_of? Hash # the supplied attribute is one of many
attr = old.delete(prefix) attr = old.delete(prefix)

View file

@ -135,8 +135,8 @@ module REXML
end end
def text=( foo ) def text=( foo )
replace = at(4).kind_of? String ? 1 : 0 replace = at(4).kind_of?(String) ? 1 : 0
self._old_put(4,replace, normalizefoo) _old_put(4, replace, normalizefoo)
end end
def root def root

View file

@ -102,7 +102,7 @@ module REXML
# @return the current line in the source # @return the current line in the source
def current_line def current_line
lines = @orig.split lines = @orig.split
res = lines.grep @buffer[0..30] res = lines.grep(@buffer[0..30])
res = res[-1] if res.kind_of? Array res = res[-1] if res.kind_of? Array
lines.index( res ) if res lines.index( res ) if res
end end

View file

@ -245,7 +245,7 @@ module REXML
def Text::unnormalize( string, doctype=nil, filter=nil, illegal=nil ) def Text::unnormalize( string, doctype=nil, filter=nil, illegal=nil )
rv = string.clone rv = string.clone
rv.gsub!( /\r\n?/, "\n" ) rv.gsub!( /\r\n?/, "\n" )
matches = rv.scan REFERENCE matches = rv.scan(REFERENCE)
return rv if matches.size == 0 return rv if matches.size == 0
rv.gsub!( NUMERICENTITY ) {|m| rv.gsub!( NUMERICENTITY ) {|m|
m=$1 m=$1

View file

@ -393,7 +393,7 @@ class Shell
end]), nil, __FILE__, __LINE__ - 1) end]), nil, __FILE__, __LINE__ - 1)
else else
args = opts.collect{|opt| '"' + opt + '"'}.join "," args = opts.collect{|opt| '"' + opt + '"'}.join(",")
eval((d = %Q[def #{ali}(*opts) eval((d = %Q[def #{ali}(*opts)
@shell.__send__(:#{command}, #{args}, *opts) @shell.__send__(:#{command}, #{args}, *opts)
end]), nil, __FILE__, __LINE__ - 1) end]), nil, __FILE__, __LINE__ - 1)

View file

@ -165,7 +165,7 @@ class Shell
return return
elsif @active_jobs.include?(command) elsif @active_jobs.include?(command)
begin begin
r = command.kill sig r = command.kill(sig)
ProcessController.inactivate(self) ProcessController.inactivate(self)
rescue rescue
print "Shell: Warn: $!\n" if @shell.verbose? print "Shell: Warn: $!\n" if @shell.verbose?

View file

@ -135,7 +135,7 @@ class Time
# #
def parse(date, now=Time.now) def parse(date, now=Time.now)
year, mon, day, hour, min, sec, zone, _ = ParseDate.parsedate(date) year, mon, day, hour, min, sec, zone, _ = ParseDate.parsedate(date)
year = yield year if year && block_given? year = yield(year) if year && block_given?
if now if now
begin begin

View file

@ -111,7 +111,7 @@ module XMLRPC
else else
begin begin
mod = Module mod = Module
klass.split("::").each {|const| mod = mod.const_get const.strip } klass.split("::").each {|const| mod = mod.const_get(const.strip)}
Thread.critical = true Thread.critical = true
# let initialize take 0 parameters # let initialize take 0 parameters

View file

@ -732,7 +732,7 @@ $x.sort!{|a,b| b-a} # reverse sort
test_ok($x == [7,5,3,2,1]) test_ok($x == [7,5,3,2,1])
# split test # split test
$x = "The Botest_ok of Mormon" $x = "The Book of Mormon"
test_ok($x.split(//).reverse!.join == $x.reverse) test_ok($x.split(//).reverse!.join == $x.reverse)
test_ok($x.reverse == $x.reverse!) test_ok($x.reverse == $x.reverse!)
test_ok("1 byte string".split(//).reverse.join(":") == "g:n:i:r:t:s: :e:t:y:b: :1") test_ok("1 byte string".split(//).reverse.join(":") == "g:n:i:r:t:s: :e:t:y:b: :1")