From 8ef5da3be1577bb5ae7f55b60cf9fedb10ecb85e Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 16 Oct 2003 17:47:19 +0000 Subject: [PATCH] consistent parentheses in assignment RHS. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/dbm/testdbm.rb | 2 +- ext/dl/lib/dl/import.rb | 4 ++-- ext/dl/sample/libc.rb | 2 +- ext/gdbm/testgdbm.rb | 2 +- ext/sdbm/testsdbm.rb | 2 +- ext/tk/lib/tk.rb | 4 ++-- ext/win32ole/sample/xml.rb | 10 +++++----- lib/cgi.rb | 4 ++-- lib/cgi/session/pstore.rb | 4 ++-- lib/irb/cmd/fork.rb | 2 +- lib/irb/completion.rb | 8 ++++---- lib/irb/workspace.rb | 2 +- lib/mkmf.rb | 2 +- lib/net/telnet.rb | 2 +- lib/resolv.rb | 2 +- lib/rexml/dtd/entitydecl.rb | 2 +- lib/rexml/dtd/notationdecl.rb | 2 +- lib/rexml/element.rb | 16 ++++++++-------- lib/rexml/light/node.rb | 4 ++-- lib/rexml/source.rb | 2 +- lib/rexml/text.rb | 2 +- lib/shell/command-processor.rb | 2 +- lib/shell/process-controller.rb | 2 +- lib/time.rb | 2 +- lib/xmlrpc/parser.rb | 2 +- sample/test.rb | 8 ++++---- 26 files changed, 48 insertions(+), 48 deletions(-) diff --git a/ext/dbm/testdbm.rb b/ext/dbm/testdbm.rb index 7ccb3d7b23..4942ffb64a 100644 --- a/ext/dbm/testdbm.rb +++ b/ext/dbm/testdbm.rb @@ -14,7 +14,7 @@ def uname_s case Config::CONFIG['host_os'] when 'cygwin' require 'Win32API' - uname = Win32API.new 'cygwin1', 'uname', 'P', 'I' + uname = Win32API.new('cygwin1', 'uname', 'P', 'I') utsname = ' ' * 100 raise 'cannot get system name' if uname.call(utsname) == -1 diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb index b71cae30ab..c0dfb5f705 100644 --- a/ext/dl/lib/dl/import.rb +++ b/ext/dl/lib/dl/import.rb @@ -79,7 +79,7 @@ module DL symty = rty + ty module_eval("module_function :#{func}") - sym = module_eval [ + sym = module_eval([ "DL::callback(\"#{symty}\"){|*args|", " sym,rdec,enc,dec = @SYM['#{func}']", " args = enc.call(args) if enc", @@ -90,7 +90,7 @@ module DL " @args = rs", " @retval", "}", - ].join("\n") + ].join("\n")) @SYM[func] = [sym,rdec,enc,dec] diff --git a/ext/dl/sample/libc.rb b/ext/dl/sample/libc.rb index 32816fd331..a1f6fbe543 100644 --- a/ext/dl/sample/libc.rb +++ b/ext/dl/sample/libc.rb @@ -39,7 +39,7 @@ module LIBC def my_compare(ptr1, ptr2) ptr1.ptr.to_s <=> ptr2.ptr.to_s end - COMPARE = callback "int my_compare(char**, char**)" + COMPARE = callback("int my_compare(char**, char**)") end diff --git a/ext/gdbm/testgdbm.rb b/ext/gdbm/testgdbm.rb index 529b0010a2..a435498640 100644 --- a/ext/gdbm/testgdbm.rb +++ b/ext/gdbm/testgdbm.rb @@ -14,7 +14,7 @@ def uname_s case Config::CONFIG['host_os'] when 'cygwin' require 'Win32API' - uname = Win32API.new 'cygwin1', 'uname', 'P', 'I' + uname = Win32API.new('cygwin1', 'uname', 'P', 'I') utsname = ' ' * 100 raise 'cannot get system name' if uname.call(utsname) == -1 diff --git a/ext/sdbm/testsdbm.rb b/ext/sdbm/testsdbm.rb index 3577d3606c..5a185fd5c4 100644 --- a/ext/sdbm/testsdbm.rb +++ b/ext/sdbm/testsdbm.rb @@ -14,7 +14,7 @@ def uname_s case Config::CONFIG['host_os'] when 'cygwin' require 'Win32API' - uname = Win32API.new 'cygwin1', 'uname', 'P', 'I' + uname = Win32API.new('cygwin1', 'uname', 'P', 'I') utsname = ' ' * 100 raise 'cannot get system name' if uname.call(utsname) == -1 diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 18f398f2aa..4cb11363e1 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -1388,7 +1388,7 @@ module Tk end end def group(*args) - w = tk_call 'wm', 'group', path, *args + w = tk_call('wm', 'group', path, *args) if args.size == 0 window(w) else @@ -3303,7 +3303,7 @@ module TkOptionDB proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ proc_str proc_str = __closed_block_check__(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 end proc{ diff --git a/ext/win32ole/sample/xml.rb b/ext/win32ole/sample/xml.rb index 6d8ac8cb66..b95d6d5275 100644 --- a/ext/win32ole/sample/xml.rb +++ b/ext/win32ole/sample/xml.rb @@ -5651,7 +5651,7 @@ class Microsoft_XMLDOM_1_0 # DOMDocument @clsid = "{2933BF90-7B36-11D2-B20E-00C04F983E60}" @progid = "Microsoft.XMLDOM.1.0" if obj.nil? - @dispatch = WIN32OLE.new @progid + @dispatch = WIN32OLE.new(@progid) else @dispatch = obj end @@ -6258,7 +6258,7 @@ class Microsoft_FreeThreadedXMLDOM_1_0 # DOMFreeThreadedDocument @clsid = "{2933BF91-7B36-11D2-B20E-00C04F983E60}" @progid = "Microsoft.FreeThreadedXMLDOM.1.0" if obj.nil? - @dispatch = WIN32OLE.new @progid + @dispatch = WIN32OLE.new(@progid) else @dispatch = obj end @@ -6992,7 +6992,7 @@ class Microsoft_XMLHTTP_1 # XMLHTTPRequest @clsid = "{ED8C108E-4349-11D2-91A4-00C04F7969E8}" @progid = "Microsoft.XMLHTTP.1" if obj.nil? - @dispatch = WIN32OLE.new @progid + @dispatch = WIN32OLE.new(@progid) else @dispatch = obj end @@ -7136,7 +7136,7 @@ class Microsoft_XMLDSO_1_0 # XMLDSOControl @clsid = "{550DDA30-0541-11D2-9CA9-0060B0EC3D39}" @progid = "Microsoft.XMLDSO.1.0" if obj.nil? - @dispatch = WIN32OLE.new @progid + @dispatch = WIN32OLE.new(@progid) else @dispatch = obj end @@ -7207,7 +7207,7 @@ class Msxml # XMLDocument @clsid = "{CFC399AF-D876-11D0-9C10-00C04FC99C8E}" @progid = "Msxml" if obj.nil? - @dispatch = WIN32OLE.new @progid + @dispatch = WIN32OLE.new(@progid) else @dispatch = obj end diff --git a/lib/cgi.rb b/lib/cgi.rb index 116cd42eef..a55c9ca4bd 100644 --- a/lib/cgi.rb +++ b/lib/cgi.rb @@ -2302,8 +2302,8 @@ class CGI else at_exit() do if defined?(CGI_PARAMS) - self.class.class_eval("remove_const(:CGI_PARAMS)") - self.class.class_eval("remove_const(:CGI_COOKIES)") + CGI.class_eval("remove_const(:CGI_PARAMS)") + CGI.class_eval("remove_const(:CGI_COOKIES)") end end end diff --git a/lib/cgi/session/pstore.rb b/lib/cgi/session/pstore.rb index eea06c2ce9..8f4beb978a 100644 --- a/lib/cgi/session/pstore.rb +++ b/lib/cgi/session/pstore.rb @@ -69,7 +69,7 @@ class CGI unless File::exist? path @hash = {} end - @p = ::PStore.new path + @p = ::PStore.new(path) end # Restore session state from the session's PStore file. @@ -114,7 +114,7 @@ if $0 == __FILE__ # :enddoc: STDIN.reopen("/dev/null") 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'} puts session['key'].class fail unless Hash === session['key'] diff --git a/lib/irb/cmd/fork.rb b/lib/irb/cmd/fork.rb index 1cc4458b13..30024dc5e0 100644 --- a/lib/irb/cmd/fork.rb +++ b/lib/irb/cmd/fork.rb @@ -3,7 +3,7 @@ module IRB module ExtendCommand class Fork "some text " def text( path = nil ) - rv = get_text path + rv = get_text(path) return rv.value unless rv.nil? nil end @@ -724,7 +724,7 @@ module REXML def []( index, name=nil) if index.kind_of? Integer raise "index (#{index}) must be >= 1" if index < 1 - name = literalize name if name + name = literalize(name) if name num = 0 child = nil @element.find { |child| @@ -1016,13 +1016,13 @@ module REXML # doc.root.attributes['x:foo'] = nil def []=( name, value ) if value.nil? # Delete the named attribute - attr = get_attribute name + attr = get_attribute(name) delete attr return end value = Attribute.new(name, value) unless value.kind_of? Attribute value.element = @element - old_attr = fetch value.name, nil + old_attr = fetch(value.name, nil) if old_attr.nil? store(value.name, value) elsif old_attr.kind_of? Hash @@ -1104,7 +1104,7 @@ module REXML prefix, name = $1, $2 prefix = '' unless prefix end - old = fetch name, nil + old = fetch(name, nil) attr = nil if old.kind_of? Hash # the supplied attribute is one of many attr = old.delete(prefix) diff --git a/lib/rexml/light/node.rb b/lib/rexml/light/node.rb index 9dafd687dd..ff8cb987f0 100644 --- a/lib/rexml/light/node.rb +++ b/lib/rexml/light/node.rb @@ -135,8 +135,8 @@ module REXML end def text=( foo ) - replace = at(4).kind_of? String ? 1 : 0 - self._old_put(4,replace, normalizefoo) + replace = at(4).kind_of?(String) ? 1 : 0 + _old_put(4, replace, normalizefoo) end def root diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb index 915b6efc27..8161750694 100644 --- a/lib/rexml/source.rb +++ b/lib/rexml/source.rb @@ -102,7 +102,7 @@ module REXML # @return the current line in the source def current_line lines = @orig.split - res = lines.grep @buffer[0..30] + res = lines.grep(@buffer[0..30]) res = res[-1] if res.kind_of? Array lines.index( res ) if res end diff --git a/lib/rexml/text.rb b/lib/rexml/text.rb index 906f4d41fc..0614e51d47 100644 --- a/lib/rexml/text.rb +++ b/lib/rexml/text.rb @@ -245,7 +245,7 @@ module REXML def Text::unnormalize( string, doctype=nil, filter=nil, illegal=nil ) rv = string.clone rv.gsub!( /\r\n?/, "\n" ) - matches = rv.scan REFERENCE + matches = rv.scan(REFERENCE) return rv if matches.size == 0 rv.gsub!( NUMERICENTITY ) {|m| m=$1 diff --git a/lib/shell/command-processor.rb b/lib/shell/command-processor.rb index 876192e8b1..ce5102a9c4 100644 --- a/lib/shell/command-processor.rb +++ b/lib/shell/command-processor.rb @@ -393,7 +393,7 @@ class Shell end]), nil, __FILE__, __LINE__ - 1) else - args = opts.collect{|opt| '"' + opt + '"'}.join "," + args = opts.collect{|opt| '"' + opt + '"'}.join(",") eval((d = %Q[def #{ali}(*opts) @shell.__send__(:#{command}, #{args}, *opts) end]), nil, __FILE__, __LINE__ - 1) diff --git a/lib/shell/process-controller.rb b/lib/shell/process-controller.rb index 26fb1d9f08..f74abfd686 100644 --- a/lib/shell/process-controller.rb +++ b/lib/shell/process-controller.rb @@ -165,7 +165,7 @@ class Shell return elsif @active_jobs.include?(command) begin - r = command.kill sig + r = command.kill(sig) ProcessController.inactivate(self) rescue print "Shell: Warn: $!\n" if @shell.verbose? diff --git a/lib/time.rb b/lib/time.rb index 115e7e9633..9d2ac558d9 100644 --- a/lib/time.rb +++ b/lib/time.rb @@ -135,7 +135,7 @@ class Time # def parse(date, now=Time.now) 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 begin diff --git a/lib/xmlrpc/parser.rb b/lib/xmlrpc/parser.rb index 233dd596fd..cfbf78f3b3 100644 --- a/lib/xmlrpc/parser.rb +++ b/lib/xmlrpc/parser.rb @@ -111,7 +111,7 @@ module XMLRPC else begin 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 # let initialize take 0 parameters diff --git a/sample/test.rb b/sample/test.rb index 2cf4eea1f4..6488558fd1 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -732,7 +732,7 @@ $x.sort!{|a,b| b-a} # reverse sort test_ok($x == [7,5,3,2,1]) # split test -$x = "The Botest_ok of Mormon" +$x = "The Book of Mormon" test_ok($x.split(//).reverse!.join == $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") @@ -1233,14 +1233,14 @@ test_ok(2**32 - 5 == (2**32-3)-2) $good = true; for i in 1000..1014 - $good = false if ((1<