From: Tanaka Akira Date: 2006-02-20T17:19:10+09:00 Subject: [ruby-dev:28347] Re: constant look up order in CVS HEAD In article <1140392909.403432.7587.nullmailer@x31.priv.netlab.jp>, Yukihiro Matsumoto writes: > )だったりしますので、元々意味のわかりにくいコードであったの > が検出されたということで、長期的には良いことではないかと思い > ます。 思ったんですが、rbconfig.rb で定義するのは Config じゃなくて RbConfig にするのはどうでしょう? Config という名前はライブラリやアプリケーションで多用されて いて名前の重複を招きますし、rbconfig.rb が Config という名前 のモジュールを定義するというのも一貫性に欠けます。 Index: instruby.rb =================================================================== RCS file: /src/ruby/instruby.rb,v retrieving revision 1.66 diff -u -p -r1.66 instruby.rb --- instruby.rb 5 Jul 2005 14:44:56 -0000 1.66 +++ instruby.rb 20 Feb 2006 07:37:49 -0000 @@ -1,7 +1,7 @@ #!./miniruby load "./rbconfig.rb" -include Config +include RbConfig srcdir = File.dirname(__FILE__) $:.unshift File.expand_path("lib", srcdir) Index: mkconfig.rb =================================================================== RCS file: /src/ruby/mkconfig.rb,v retrieving revision 1.42 diff -u -p -r1.42 mkconfig.rb --- mkconfig.rb 10 Nov 2005 23:21:52 -0000 1.42 +++ mkconfig.rb 20 Feb 2006 07:37:49 -0000 @@ -26,7 +26,7 @@ print %[ # This file was created by #{mkconfig} when ruby was built. Any # changes made to this file will be lost the next time ruby is built. -module Config +module RbConfig RUBY_VERSION == "#{version}" or raise "ruby lib version (#{version}) doesn't match executable version (\#{RUBY_VERSION})" @@ -116,14 +116,14 @@ print <$topdir)) + RbConfig.expand(extout = "#$extout", RbConfig::CONFIG.merge("topdir"=>$topdir)) if $install - Config.expand(dest = "#{$destdir}#{$rubylibdir}") + RbConfig.expand(dest = "#{$destdir}#{$rubylibdir}") FileUtils.cp_r(extout+"/.", dest, :verbose => true, :noop => $dryrun) exit end @@ -472,7 +472,7 @@ unless $destdir.to_s.empty? $mflags.defined?("DESTDIR") or $mflags << "DESTDIR=#{$destdir}" end if !$extlist.empty? and $extupdate - rm_f(Config::CONFIG["LIBRUBY_SO"]) + rm_f(RbConfig::CONFIG["LIBRUBY_SO"]) end puts "making #{rubies.join(', ')}" $stdout.flush Index: ext/dl/extconf.rb =================================================================== RCS file: /src/ruby/ext/dl/extconf.rb,v retrieving revision 1.16 diff -u -p -r1.16 extconf.rb --- ext/dl/extconf.rb 18 Oct 2005 02:03:50 -0000 1.16 +++ ext/dl/extconf.rb 20 Feb 2006 07:37:51 -0000 @@ -1,6 +1,6 @@ require 'mkmf' -if( Config::CONFIG['CC'] =~ /gcc/ ) +if( RbConfig::CONFIG['CC'] =~ /gcc/ ) $CFLAGS << " -fno-defer-pop -fno-omit-frame-pointer" end Index: ext/iconv/charset_alias.rb =================================================================== RCS file: /src/ruby/ext/iconv/charset_alias.rb,v retrieving revision 1.9 diff -u -p -r1.9 charset_alias.rb --- ext/iconv/charset_alias.rb 13 Oct 2005 14:33:25 -0000 1.9 +++ ext/iconv/charset_alias.rb 20 Feb 2006 07:37:51 -0000 @@ -6,8 +6,8 @@ require 'optparse' # http://www.ctan.org/tex-archive/macros/texinfo/texinfo/intl/config.charset # Fri, 30 May 2003 00:09:00 GMT' -OS = Config::CONFIG["target_os"] -SHELL = Config::CONFIG['SHELL'] +OS = RbConfig::CONFIG["target_os"] +SHELL = RbConfig::CONFIG['SHELL'] class Hash::Ordered < Hash def [](key) Index: lib/mkmf.rb =================================================================== RCS file: /src/ruby/lib/mkmf.rb,v retrieving revision 1.235 diff -u -p -r1.235 mkmf.rb --- lib/mkmf.rb 5 Feb 2006 07:37:38 -0000 1.235 +++ lib/mkmf.rb 20 Feb 2006 07:37:51 -0000 @@ -5,7 +5,7 @@ require 'rbconfig' require 'fileutils' require 'shellwords' -CONFIG = Config::MAKEFILE_CONFIG +CONFIG = RbConfig::MAKEFILE_CONFIG ORIG_LIBPATH = ENV['LIB'] CXX_EXT = %w[cc cxx cpp] @@ -112,10 +112,10 @@ end topdir = File.dirname(libdir = File.dirname(__FILE__)) extdir = File.expand_path("ext", topdir) $extmk = File.expand_path($0)[0, extdir.size+1] == extdir+"/" -if not $extmk and File.exist?(Config::CONFIG["archdir"] + "/ruby.h") - $hdrdir = $topdir = Config::CONFIG["archdir"] +if not $extmk and File.exist?(RbConfig::CONFIG["archdir"] + "/ruby.h") + $hdrdir = $topdir = RbConfig::CONFIG["archdir"] elsif File.exist?(($top_srcdir ||= topdir) + "/ruby.h") and - File.exist?(($topdir ||= Config::CONFIG["topdir"]) + "/config.h") + File.exist?(($topdir ||= RbConfig::CONFIG["topdir"]) + "/config.h") $hdrdir = $top_srcdir else abort "can't find header files for ruby." @@ -259,7 +259,7 @@ ensure end def link_command(ldflags, opt="", libpath=$LIBPATH) - Config::expand(TRY_LINK.dup, + RbConfig::expand(TRY_LINK.dup, CONFIG.merge('hdrdir' => $hdrdir.quote, 'src' => CONFTEST_C, 'INCFLAGS' => $INCFLAGS, @@ -273,13 +273,13 @@ def link_command(ldflags, opt="", libpat end def cc_command(opt="") - Config::expand("$(CC) -c #$INCFLAGS -I$(hdrdir) " \ + RbConfig::expand("$(CC) -c #$INCFLAGS -I$(hdrdir) " \ "#$CPPFLAGS #$CFLAGS #$ARCH_FLAG #{opt} #{CONFTEST_C}", CONFIG.merge('hdrdir' => $hdrdir.quote)) end def cpp_command(outfile, opt="") - Config::expand("$(CPP) #$INCFLAGS -I$(hdrdir) " \ + RbConfig::expand("$(CPP) #$INCFLAGS -I$(hdrdir) " \ "#$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}", CONFIG.merge('hdrdir' => $hdrdir.quote)) end @@ -484,7 +484,7 @@ end def install_files(mfile, ifiles, map = nil, srcprefix = nil) ifiles or return srcprefix ||= '$(srcdir)' - Config::expand(srcdir = srcprefix.dup) + RbConfig::expand(srcdir = srcprefix.dup) dirs = [] path = Hash.new {|h, i| h[i] = dirs.push([i])[-1]} ifiles.each do |files, dir, prefix| @@ -972,7 +972,7 @@ RUBY_INSTALL_NAME = #{CONFIG['RUBY_INSTA RUBY_SO_NAME = #{CONFIG['RUBY_SO_NAME']} arch = #{CONFIG['arch']} sitearch = #{CONFIG['sitearch']} -ruby_version = #{Config::CONFIG['ruby_version']} +ruby_version = #{RbConfig::CONFIG['ruby_version']} ruby = #{$ruby} RUBY = $(ruby#{sep}) RM = #{config_string('RM') || '$(RUBY) -run -e rm -- -f'} @@ -1028,7 +1028,7 @@ def create_makefile(target, srcprefix = end srcprefix ||= '$(srcdir)' - Config::expand(srcdir = srcprefix.dup) + RbConfig::expand(srcdir = srcprefix.dup) if not $objs $objs = [] @@ -1290,7 +1290,7 @@ def init_mkmf(config = CONFIG) $objs = nil $srcs = nil $libs = "" - if $enable_shared or Config.expand(config["LIBRUBY"].dup) != Config.expand(config["LIBRUBY_A"].dup) + if $enable_shared or RbConfig.expand(config["LIBRUBY"].dup) != RbConfig.expand(config["LIBRUBY_A"].dup) $LIBRUBYARG = config['LIBRUBYARG'] end @@ -1333,20 +1333,20 @@ when $bccwin $nmake = ?b if /Borland/i =~ `#{make} -h` end -Config::CONFIG["srcdir"] = CONFIG["srcdir"] = +RbConfig::CONFIG["srcdir"] = CONFIG["srcdir"] = $srcdir = arg_config("--srcdir", File.dirname($0)) $configure_args["--topsrcdir"] ||= $srcdir if $curdir = arg_config("--curdir") - Config.expand(curdir = $curdir.dup) + RbConfig.expand(curdir = $curdir.dup) else curdir = $curdir = "." end -unless File.expand_path(Config::CONFIG["topdir"]) == File.expand_path(curdir) +unless File.expand_path(RbConfig::CONFIG["topdir"]) == File.expand_path(curdir) CONFIG["topdir"] = $curdir - Config::CONFIG["topdir"] = curdir + RbConfig::CONFIG["topdir"] = curdir end $configure_args["--topdir"] ||= $curdir -$ruby = arg_config("--ruby", File.join(Config::CONFIG["bindir"], CONFIG["ruby_install_name"])) +$ruby = arg_config("--ruby", File.join(RbConfig::CONFIG["bindir"], CONFIG["ruby_install_name"])) split = Shellwords.method(:shellwords).to_proc Index: lib/rdoc/ri/ri_paths.rb =================================================================== RCS file: /src/ruby/lib/rdoc/ri/ri_paths.rb,v retrieving revision 1.4 diff -u -p -r1.4 ri_paths.rb --- lib/rdoc/ri/ri_paths.rb 9 Feb 2004 08:46:24 -0000 1.4 +++ lib/rdoc/ri/ri_paths.rb 20 Feb 2006 07:37:51 -0000 @@ -26,9 +26,9 @@ module RI DOC_DIR = "doc/rdoc" - version = Config::CONFIG['ruby_version'] + version = RbConfig::CONFIG['ruby_version'] - base = File.join(Config::CONFIG['datadir'], "ri", version) + base = File.join(RbConfig::CONFIG['datadir'], "ri", version) SYSDIR = File.join(base, "system") SITEDIR = File.join(base, "site") homedir = ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH'] Index: lib/webrick/httpservlet/cgihandler.rb =================================================================== RCS file: /src/ruby/lib/webrick/httpservlet/cgihandler.rb,v retrieving revision 1.7 diff -u -p -r1.7 cgihandler.rb --- lib/webrick/httpservlet/cgihandler.rb 20 Feb 2006 00:15:35 -0000 1.7 +++ lib/webrick/httpservlet/cgihandler.rb 20 Feb 2006 07:37:51 -0000 @@ -17,9 +17,9 @@ module WEBrick module HTTPServlet class CGIHandler < AbstractServlet - Ruby = File::join(::Config::CONFIG['bindir'], - ::Config::CONFIG['ruby_install_name']) - Ruby << ::Config::CONFIG['EXEEXT'] + Ruby = File::join(RbConfig::CONFIG['bindir'], + RbConfig::CONFIG['ruby_install_name']) + Ruby << RbConfig::CONFIG['EXEEXT'] CGIRunner = "\"#{Ruby}\" \"#{WEBrick::Config::LIBDIR}/httpservlet/cgi_runner.rb\"" def initialize(server, name) Index: test/dbm/test_dbm.rb =================================================================== RCS file: /src/ruby/test/dbm/test_dbm.rb,v retrieving revision 1.9 diff -u -p -r1.9 test_dbm.rb --- test/dbm/test_dbm.rb 5 Oct 2005 16:15:14 -0000 1.9 +++ test/dbm/test_dbm.rb 20 Feb 2006 07:37:51 -0000 @@ -12,7 +12,7 @@ if defined? DBM class TestDBM < Test::Unit::TestCase def TestDBM.uname_s require 'rbconfig' - case Config::CONFIG['host_os'] + case RbConfig::CONFIG['host_os'] when 'cygwin' require 'Win32API' uname = Win32API.new('cygwin1', 'uname', 'P', 'I') @@ -21,7 +21,7 @@ if defined? DBM utsname.unpack('A20' * 5)[0] else - Config::CONFIG['host_os'] + RbConfig::CONFIG['host_os'] end end SYSTEM = uname_s Index: test/gdbm/test_gdbm.rb =================================================================== RCS file: /src/ruby/test/gdbm/test_gdbm.rb,v retrieving revision 1.9 diff -u -p -r1.9 test_gdbm.rb --- test/gdbm/test_gdbm.rb 12 Aug 2005 15:53:04 -0000 1.9 +++ test/gdbm/test_gdbm.rb 20 Feb 2006 07:37:51 -0000 @@ -12,7 +12,7 @@ if defined? GDBM class TestGDBM < Test::Unit::TestCase def TestGDBM.uname_s require 'rbconfig' - case Config::CONFIG['host_os'] + case RbConfig::CONFIG['host_os'] when 'cygwin' require 'Win32API' uname = Win32API.new('cygwin1', 'uname', 'P', 'I') @@ -21,7 +21,7 @@ if defined? GDBM utsname.unpack('A20' * 5)[0] else - Config::CONFIG['host_os'] + RbConfig::CONFIG['host_os'] end end SYSTEM = uname_s Index: test/ruby/envutil.rb =================================================================== RCS file: /src/ruby/test/ruby/envutil.rb,v retrieving revision 1.7 diff -u -p -r1.7 envutil.rb --- test/ruby/envutil.rb 3 Feb 2006 09:15:36 -0000 1.7 +++ test/ruby/envutil.rb 20 Feb 2006 07:37:51 -0000 @@ -20,8 +20,8 @@ module EnvUtil begin require "rbconfig" File.join( - Config::CONFIG["bindir"], - Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"] + RbConfig::CONFIG["bindir"], + RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"] ) rescue LoadError "ruby" Index: test/soap/calc/test_calc_cgi.rb =================================================================== RCS file: /src/ruby/test/soap/calc/test_calc_cgi.rb,v retrieving revision 1.16 diff -u -p -r1.16 test_calc_cgi.rb --- test/soap/calc/test_calc_cgi.rb 22 May 2005 13:03:31 -0000 1.16 +++ test/soap/calc/test_calc_cgi.rb 20 Feb 2006 07:37:51 -0000 @@ -12,8 +12,8 @@ module Calc class TestCalcCGI < Test::Unit::TestCase # This test shuld be run after installing ruby. RUBYBIN = File.join( - Config::CONFIG["bindir"], - Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"] + RbConfig::CONFIG["bindir"], + RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"] ) RUBYBIN << " -d" if $DEBUG Index: test/soap/header/test_authheader_cgi.rb =================================================================== RCS file: /src/ruby/test/soap/header/test_authheader_cgi.rb,v retrieving revision 1.2 diff -u -p -r1.2 test_authheader_cgi.rb --- test/soap/header/test_authheader_cgi.rb 22 May 2005 13:03:32 -0000 1.2 +++ test/soap/header/test_authheader_cgi.rb 20 Feb 2006 07:37:51 -0000 @@ -14,8 +14,8 @@ module Header class TestAuthHeaderCGI < Test::Unit::TestCase # This test shuld be run after installing ruby. RUBYBIN = File.join( - Config::CONFIG["bindir"], - Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"] + RbConfig::CONFIG["bindir"], + RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"] ) RUBYBIN << " -d" if $DEBUG Index: test/soap/ssl/test_ssl.rb =================================================================== RCS file: /src/ruby/test/soap/ssl/test_ssl.rb,v retrieving revision 1.5 diff -u -p -r1.5 test_ssl.rb --- test/soap/ssl/test_ssl.rb 10 Oct 2005 04:24:06 -0000 1.5 +++ test/soap/ssl/test_ssl.rb 20 Feb 2006 07:37:51 -0000 @@ -16,8 +16,8 @@ class TestSSL < Test::Unit::TestCase DIR = File.dirname(File.expand_path(__FILE__)) require 'rbconfig' RUBY = File.join( - Config::CONFIG["bindir"], - Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"] + RbConfig::CONFIG["bindir"], + RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"] ) def setup Index: win32/mkexports.rb =================================================================== RCS file: /src/ruby/win32/mkexports.rb,v retrieving revision 1.5 diff -u -p -r1.5 mkexports.rb --- win32/mkexports.rb 5 Nov 2005 04:43:46 -0000 1.5 +++ win32/mkexports.rb 20 Feb 2006 07:37:52 -0000 @@ -1,6 +1,6 @@ #!./miniruby -s -module Config +module RbConfig autoload :CONFIG, "rbconfig" end @@ -112,7 +112,7 @@ end class Exports::Mingw < Exports def self.nm - @@nm ||= Config::CONFIG["NM"] + @@nm ||= RbConfig::CONFIG["NM"] end def each_export(objs) Index: win32/resource.rb =================================================================== RCS file: /src/ruby/win32/resource.rb,v retrieving revision 1.10 diff -u -p -r1.10 resource.rb --- win32/resource.rb 3 Mar 2005 09:38:40 -0000 1.10 +++ win32/resource.rb 20 Feb 2006 07:37:52 -0000 @@ -2,7 +2,7 @@ require 'rbconfig' -CONFIG = Config::MAKEFILE_CONFIG +CONFIG = RbConfig::MAKEFILE_CONFIG fversion = "#{CONFIG['MAJOR']},#{CONFIG['MINOR']},#{CONFIG['TEENY']},0" -- [田中 哲][たなか あきら][Tanaka Akira]