[前][次][番号順一覧][スレッド一覧]

ruby-changes:25167

From: knu <ko1@a...>
Date: Tue, 16 Oct 2012 17:56:58 +0900 (JST)
Subject: [ruby-changes:25167] knu:r37217 (ruby_1_8): Merge r32233 and r32320 from ruby_1_8_7.

knu	2012-10-16 17:54:53 +0900 (Tue, 16 Oct 2012)

  New Revision: 37217

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37217

  Log:
    Merge r32233 and r32320 from ruby_1_8_7.
    
    * ext/tk/extconf.rb: copy from trunk, as requested by Hidetoshi NAGAI.
    
    * ext/tk/extconf.rb (intptr_t, uintptr_t): support for the latest ActiveTcl with mingw.

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/ext/tk/config_list.in
    branches/ruby_1_8/ext/tk/extconf.rb

Index: ruby_1_8/ext/tk/config_list.in
===================================================================
--- ruby_1_8/ext/tk/config_list.in	(revision 37216)
+++ ruby_1_8/ext/tk/config_list.in	(revision 37217)
@@ -1,12 +1,16 @@
 ##############################################
 # configure options for Ruby/Tk
-# release date:  2009-07-28
+# release date:  2011-06-05
 ##############################################
 with tk-old-extconf
 with ActiveTcl
 with tk-shlib-search-path
 enable tcltk-stubs
 with tcltkversion
+enable tcl-h-ver-check
+enable tk-h-ver-check
+with tcl-build-dir
+with tk-build-dir
 with tcl-config
 with tk-config
 with tclConfig-dir
Index: ruby_1_8/ext/tk/extconf.rb
===================================================================
--- ruby_1_8/ext/tk/extconf.rb	(revision 37216)
+++ ruby_1_8/ext/tk/extconf.rb	(revision 37217)
@@ -5,12 +5,14 @@
 require 'mkmf'
 
 TkLib_Config = {}
-TkLib_Config['search_versions'] = 
+TkLib_Config['search_versions'] =
   # %w[8.9 8.8 8.7 8.6 8.5 8.4 8.3 8.2 8.1 8.0 7.6 4.2]
   # %w[8.7 8.6 8.5 8.4 8.3 8.2 8.1 8.0]
   %w[8.7 8.6 8.5 8.4 8.0] # to shorten search steps
 
+TkLib_Config['major_nums'] = '87'
 
+
 ##############################################################
 # use old extconf.rb ?
 ##############################################################
@@ -23,10 +25,10 @@
 ##############################################################
 # check configs
 ##############################################################
-$cleanfiles << 'config_list'
+($cleanfiles ||= "") << 'config_list'
 config_list_file = 'config_list'
 config_list_file_source = File.join(File.dirname(__FILE__),'config_list.in')
-if !File.exist?(config_list_file) || 
+if !File.exist?(config_list_file) ||
     File.ctime(config_list_file_source) > File.ctime(config_list_file)
   old_config_list_file = config_list_file_source
 else
@@ -92,7 +94,7 @@
 
 else
   makefile = 'Makefile'
-  if File.exist?(makefile) && 
+  if File.exist?(makefile) &&
       File.ctime(config_list_file) > File.ctime(makefile)
     # no need to update Makefile
     exit
@@ -111,23 +113,25 @@
  /darwin/ =~ RUBY_PLATFORM
 end
 
+def maybe_64bit?
+  /64|universal/ =~ RUBY_PLATFORM
+end
+
 def check_tcltk_version(version)
   return [nil, nil] unless version.kind_of? String
 
-  version = version.strip
+  tclver, tkver = version.split(',')
+  tclver = tclver.strip
+  return [tclver, tkver.strip] if tkver
 
-  tclver = version.dup
-  tkver  = version.dup
-
   dot = major = minor_dot = minor = plvl_dot = plvl = ext = nil
-
-  if version =~ /^(\d)(\.?)(\d)(\.?)(\d*)(.*)$/
+  if tclver =~ /^(\d)(\.?)(\d)(\.?)(\d*)(.*)$/
     major = $1; minor_dot = $2; minor = $3; plvl_dot = $4; plvl = $5; ext = $6
     dot = ! minor_dot.empty?
     if plvl_dot.empty? && ! plvl.empty?
       minor << plvl
     end
-  elsif version =~ /^(\d)(\.?)(\d?)(.*)$/
+  elsif tclver =~ /^(\d)(\.?)(\d?)(.*)$/
     major = $1; minor_dot = $2; minor = $3; ext = $4
     dot = ! minor_dot.empty?
   else # unknown -> believe user
@@ -140,9 +144,12 @@
     tkver  = "4" + ((dot)? ".": "") + ((minor.empty)? "": "2") + ext
   elsif major == "4" # Tk4.2 ( not support Tkversion < 4.2 )
     # Tcl7.6
+    tkver = tclver
     tclver = "7" + ((dot)? ".": "") + ((minor.empty)? "": "6") + ext
   end
 
+  tkver = tclver unless tkver
+
   [tclver, tkver]
 end
 
@@ -187,22 +194,34 @@
   if CROSS_COMPILING
   elsif is_win32?
     if TkLib_Config["ActiveTcl"]
-      path_head.concat ["c:/ActiveTcl", "c:/Program Files/ActiveTcl"]
+      path_head.concat ["c:/ActiveTcl", "c:/Program Files/ActiveTcl",
+                        "c:/Program Files (x86)/ActiveTcl"]
     end
     path_head.concat [
-      "c:/Tcl", "c:/Program Files/Tcl",
-      "/Tcl", "/Program Files/Tcl"
+      "c:/Tcl", "c:/Program Files/Tcl", "c:/Program Files (x86)/Tcl",
+      "/Tcl", "/Program Files/Tcl", "/Program Files (x86)/Tcl"
     ]
-    path_head.each{|dir| path_dirs << "#{dir}"}
+    path_head.uniq!
+    #path_head.each{|dir| path_dirs << dir.dup if File.directory? dir}
+    path_head.each{|dir| path_dirs << File.expand_path(dir) if File.directory? dir}
 
+    # for MinGW
+    ["/usr/local/lib64", "/usr/lib64", "/usr/local/lib", "/usr/lib"].each{|dir|
+      #path_dirs << dir if File.directory? dir
+      path_dirs << File.expand_path(dir) if File.directory? dir
+    }
+    path_dirs |= ENV['LIBRARY_PATH'].split(';').find_all{|dir| File.directory? dir}.map{|dir| File.expand_path(dir)} if ENV['LIBRARY_PATH']
+    path_dirs |= ENV['PATH'].split(';').find_all{|dir| File.directory? dir}.map{|dir| File.expand_path(dir)} if ENV['PATH']
+
   else
     [
-      '/opt', '/pkg', '/share', 
+      '/opt', '/pkg', '/share',
       '/usr/local/opt', '/usr/local/pkg', '/usr/local/share', '/usr/local',
       '/usr/opt', '/usr/pkg', '/usr/share', '/usr/contrib', '/usr'
     ].each{|dir|
       next unless File.directory?(dir)
 
+      path_dirs << "#{dir}/lib64" if maybe_64bit?
       path_dirs << "#{dir}/lib"
       path_dirs << "#{dir}" unless Dir.glob("#{dir}/lib*.*", File::FNM_CASEFOLD).empty?
 
@@ -268,7 +287,7 @@
   end
 
   # framework is disabled?
-  if with_config("tcltk-framework") == false || 
+  if with_config("tcltk-framework") == false ||
       enable_config("tcltk-framework") == false
    return false
   end
@@ -276,7 +295,7 @@
   use_framework ||= (framework_dir = with_config("tcltk-framework"))
   if framework_dir.kind_of? String
     TkLib_Config["tcltk-framework"] = framework_dir.strip.chomp('/')
-    return [File.join(TkLib_Config["tcltk-framework"], 'Tcl.framework'), 
+    return [File.join(TkLib_Config["tcltk-framework"], 'Tcl.framework'),
             File.join(TkLib_Config["tcltk-framework"], 'Tk.framework')]
   end
 
@@ -287,7 +306,7 @@
   end
 
   paths = [
-    #"~/Library/Frameworks", 
+    #"~/Library/Frameworks",
     "/Library/Frameworks",
     "/Network/Library/Frameworks", "/System/Library/Frameworks"
   ]
@@ -305,7 +324,7 @@
 
 def collect_tcltk_defs(tcl_defs_str, tk_defs_str)
   conflicts = [
-    'PACKAGE_NAME', 'PACKAGE_TARNAME', 'PACKAGE_VERSION', 
+    'PACKAGE_NAME', 'PACKAGE_TARNAME', 'PACKAGE_VERSION',
     'PACKAGE_STRING', 'PACKAGE_BUGREPORT'
   ]
 
@@ -347,11 +366,11 @@
 
   defs.delete_if{|name,value|
     conflicts.include?(name) ||
-      ( (vtcl = tcl_defs.assoc(name)) && (vtk = tk_defs.assoc(name)) && 
+      ( (vtcl = tcl_defs.assoc(name)) && (vtk = tk_defs.assoc(name)) &&
           vtcl != vtk )
   }
 
-  defs.map{|ary| s = ary.join(''); (s.strip.empty?)? "": "-D" << s}.join(' ')
+  defs.map{|ary| s = ary.join(''); (s.strip.empty?)? "": "-D" << s}
 end
 
 def parse_tclConfig(file)
@@ -371,8 +390,8 @@
 end
 
 def get_libpath(lib_flag, lib_spec)
-  # get libpath fro {TCL,Tk}_LIB_FLAG and {TCL,Tk}_LIB_SPEC
-  libpath = lib_spec.gsub(/(#{lib_flag}|-L)/, "").strip
+  # get libpath from {TCL,Tk}_LIB_FLAG and {TCL,Tk}_LIB_SPEC
+  lib_spec.gsub(/(#{lib_flag}|-L)/, "").strip
 end
 
 def get_tclConfig_dirs
@@ -387,19 +406,21 @@
       end
       dirs.concat [
         "c:/ActiveTcl*/lib", "c:/Tcl*/lib",
-        "c:/Program Files/ActiveTcl*/lib", "c:/Program Files/Tcl*/lib",
+        "c:/Program Files*/ActiveTcl*/lib", "c:/Program Files*/Tcl*/lib",
         "/ActiveTcl*/lib", "/Tcl*/lib",
-        "/Program Files/ActiveTcl*/lib", "/Program Files/Tcl*/lib"
+        "/Program Files*/ActiveTcl*/lib", "/Program Files*/Tcl*/lib"
       ]
     else
       dirs = [
-        "c:/Tcl*/lib", "c:/Program Files/Tcl*/lib",
-        "/Tcl*/lib", "/Program Files/Tcl*/lib"
+        "c:/Tcl*/lib", "c:/Program Files*/Tcl*/lib",
+        "/Tcl*/lib", "/Program Files*/Tcl*/lib"
       ]
     end
-    dirs.collect{|d| Dir.glob(d, File::FNM_CASEFOLD)}.flatten!
-    dirs |= dirs
+    dirs = dirs.collect{|d| Dir.glob(d, File::FNM_CASEFOLD)}.flatten.uniq
 
+    dirs |= ENV['LIBRARY_PATH'].split(';')  if ENV['LIBRARY_PATH']
+    dirs |= ENV['PATH'].split(';')  if ENV['PATH']
+
     exeext = RbConfig::CONFIG['EXEEXT']
     ENV['PATH'].split(File::PATH_SEPARATOR).each{|dir|
       dir.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
@@ -433,7 +454,7 @@
           File.join(base, 'Tk.framework', 'Versions', 'Current')
         ]
 
-        Dir.glob(File.join(base, 'Tcl.framework', 
+        Dir.glob(File.join(base, 'Tcl.framework',
                            'Versions', '*')).sort.reverse.each{|dir|
           next if dir =~ /Current/
           config_dir << [dir, dir.gsub(/Tcl/, 'Tk')]
@@ -443,22 +464,28 @@
       end
     end
 
-    config_dir.concat [
-      RbConfig::CONFIG['libdir'],
-      File.join(RbConfig::CONFIG['exec_prefix'], 'lib'),
-      File.join(RbConfig::CONFIG['prefix'], 'lib'), 
-      "/usr/local/opt/lib", "/usr/local/pkg/lib", "/usr/local/share/lib", 
-      "/usr/local/lib", "/usr/opt/lib", "/usr/pkg/lib", 
-      "/usr/share/lib", "/usr/contrib/lib", "/usr/lib"
-    ]
+    config_dir << RbConfig::CONFIG['libdir']
 
+    ((maybe_64bit?)? ['lib64', 'lib']: ['lib']).each{|dir|
+      config_dir.concat [
+        File.join(RbConfig::CONFIG['exec_prefix'], dir),
+        File.join(RbConfig::CONFIG['prefix'], dir),
+        "/usr/local/opt/#{dir}", "/usr/local/pkg/#{dir}",
+        "/usr/local/share/#{dir}", "/usr/local/#{dir}",
+        "/usr/opt/#{dir}", "/usr/pkg/#{dir}", "/usr/share/#{dir}",
+        "/usr/contrib/#{dir}", "/usr/#{dir}"
+      ]
+    }
+
     config_dir.concat [
-      '/opt', '/pkg', '/share', 
+      '/opt', '/pkg', '/share',
       '/usr/local/opt', '/usr/local/pkg', '/usr/local/share', '/usr/local',
       '/usr/opt', '/usr/pkg', '/usr/share', '/usr/contrib', '/usr'
     ].map{|dir|
-      Dir.glob(dir + '/{tcltk,tcl,tk}[87]*/lib', File::FNM_CASEFOLD)
-      Dir.glob(dir + '/{tcltk,tcl,tk}[87]*', File::FNM_CASEFOLD)
+      Dir.glob(dir + "/{tcltk,tcl,tk}[#{TkLib_Config['major_nums']}*/lib",
+               File::FNM_CASEFOLD)
+      Dir.glob(dir + "/{tcltk,tcl,tk}[#{TkLib_Config['major_nums']}*",
+               File::FNM_CASEFOLD)
       Dir.glob(dir + '/{tcltk,tcl,tk}/lib', File::FNM_CASEFOLD)
       Dir.glob(dir + '/{tcltk,tcl,tk}', File::FNM_CASEFOLD)
     }.flatten!
@@ -483,14 +510,14 @@
     }
 
     paths = [
-      #"~/Library/Frameworks", 
+      #"~/Library/Frameworks",
       "/Library/Frameworks",
       "/Network/Library/Frameworks", "/System/Library/Frameworks"
     ]
     paths.reverse! unless TkLib_Config["ActiveTcl"]
 
-    paths.each{|framework|
-      base = File.expand_path(framework)
+    paths.each{|frmwk|
+      base = File.expand_path(frmwk)
       config_dir << [
         File.join(base, 'Tcl.framework'), File.join(base, 'Tk.framework')
       ]
@@ -500,7 +527,7 @@
         File.join(base, 'Tk.framework', 'Versions', 'Current')
       ]
 
-      Dir.glob(File.join(base, 'Tcl.framework', 
+      Dir.glob(File.join(base, 'Tcl.framework',
                          'Versions', '*')).sort.reverse.each{|dir|
         next if dir =~ /Current/
         config_dir << [dir, dir.gsub(/Tcl/, 'Tk')]
@@ -511,7 +538,25 @@
   config_dir
 end
 
-def libcheck_for_tclConfig(dir, tclconf, tkconf)
+def get_ext_list()
+  exts = [CONFIG['DLEXT']]
+  exts.concat %w(dll lib) if is_win32?
+  exts.concat %w(bundle dylib) if is_macosx? || /nextstep|openstep|rhapsody/ =~ RUBY_PLATFORM
+
+  if enable_config("shared") == false
+    [CONFIG['LIBEXT'], "a"].concat exts
+  else
+    exts.concat [CONFIG['LIBEXT'], "a"]
+  end
+
+  if is_win32?
+    exts.map!{|ext| [ext.downcase, ext.upcase]}.flatten!
+  end
+
+  exts
+end
+
+def libcheck_for_tclConfig(tcldir, tkdir, tclconf, tkconf)
   tcllib_ok = tklib_ok = false
 
   if TkLib_Config["tcltk-stubs"]
@@ -524,32 +569,122 @@
     tkfunc  = "Tk_Init"
   end
 
-  libpath = $LIBPATH
+  incflags = ($INCFLAGS ||= "").dup
+  libpath = ($LIBPATH ||= []).dup
+  libs_param = ($libs ||= "").dup
   tcllibs = nil
+  mkmf_param = nil
 
-  begin
-    tcllib_ok ||= Dir.glob(File.join(dir, "*tcl#{stub}#{tclconf['TCL_MAJOR_VERSION']}{.,}#{tclconf['TCL_MINOR_VERSION']}*.*"), File::FNM_CASEFOLD).find{|file|
-      if file =~ /^.*(tcl#{stub}#{tclconf['TCL_MAJOR_VERSION']}(\.|)#{tclconf['TCL_MINOR_VERSION']}.*)\.[^.]*$/
-        #puts "check #{file} #{$1} #{tclfunc} #{dir}"
-        #find_library($1, tclfunc, dir)
-        tcllibs = append_library($libs, $1)
-        $LIBPATH = libpath | [dir]
-        try_func(tclfunc, tcllibs)
+  tclver, tkver = TkLib_Config["tcltkversion"]
+  exts = "(" + get_ext_list.join('|') + ")"
+
+  if tclver
+    tcl_glob = "*tcl#{stub}#{tclver}.*"
+    tcl_regexp = /^.*(tcl#{stub}#{tclver}.*)\.(#{exts}).*$/
+  elsif tclconf
+    tcl_glob = "*tcl#{stub}#{tclconf['TCL_MAJOR_VERSION']}{.,}#{tclconf['TCL_MINOR_VERSION']}*.*"
+    tcl_regexp = /^.*(tcl#{stub}#{tclconf['TCL_MAJOR_VERSION']}(?:\.|)#{tclconf['TCL_MINOR_VERSION']}.*)\.(#{exts}).*$/
+  end
+  if tkver
+    tk_glob = "*tk#{stub}#{tkver}.*"
+    tk_regexp = /^.*(tk#{stub}#{tkver}.*)\.(#{exts}).*$/
+  elsif tkconf
+    tk_glob = "*tk#{stub}#{tkconf['TK_MAJOR_VERSION']}{.,}#{tkconf['TK_MINOR_VERSION']}*.*"
+    tk_regexp = /^.*(tk#{stub}#{tkconf['TK_MAJOR_VERSION']}(?:\.|)#{tkconf['TK_MINOR_VERSION']}.*)\.#{exts}.*$/
+  end
+
+  tcllib_ok ||= !tclconf || Dir.glob(File.join(tcldir, tcl_glob), File::FNM_CASEFOLD).find{|file|
+    if file =~ tcl_regexp
+      libname = $1
+      ext = $2.downcase
+      begin
+        $INCFLAGS = incflags.dup << " " << tclconf["TCL_INCLUDE_SPEC"]
+        #puts "check #{file} #{$1} #{tclfunc} #{tcldir}"
+        #find_library($1, tclfunc, tcldir)
+        if (tclconf && tclconf["TCL_SHARED_BUILD"] == "0") ||
+            (ext != CONFIG['DLEXT'] && ext == CONFIG['LIBEXT']) || ext == "a"
+          # static link
+          tcllibs = $libs + " -DSTATIC_BUILD " + file.quote
+
+          # FIX ME: avoid pathname trouble (fail to find) on MinGW.
+          #   e.g. TCL_INCLUDE_SPEC describes "-I/usr/local/include",
+          #        but compiler can find "-IC:/msys/1.0/local/include" only.
+          $INCFLAGS << " -I" << File.join(File.dirname(File.dirname(file)),"include") if is_win32?
+        else
+          tcllibs = append_library($libs, libname)
+          tcllibs = "-L#{tcldir.quote} -Wl,-R#{tcldir.quote} " + tcllibs
+
+          # FIX ME: avoid pathname trouble (fail to find) on MinGW.
+          $INCFLAGS << " -I" << File.join(File.dirname(tcldir),"include") if is_win32?
+        end
+
+        $LIBPATH = libpath | [tcldir]
+        try_func(tclfunc, tcllibs, ["tcl.h"]) ||
+          ( try_func(tclfunc, tcllibs << " " << tclconf['TCL_LIBS'], ["tcl.h"]) if tclconf['TCL_LIBS'] )
+
+      ensure
+        mkmf_param = {
+          'PATH' => file,
+          'LIBNAME' => libname,
+          'libs' => tcllibs.dup,
+          'INCFLAGS' => $INCFLAGS.dup,
+          'LIBPATH' => $LIBPATH.dup,
+        }
+        $LIBPATH = libpath.dup
+        $libs = libs_param.dup
       end
-    }
-    tklib_ok ||= Dir.glob(File.join(dir, "*tk#{stub}#{tkconf['TK_MAJOR_VERSION']}{.,}#{tkconf['TK_MINOR_VERSION']}*.*"), File::FNM_CASEFOLD).find{|file|
-      if file =~ /^.*(tk#{stub}#{tkconf['TK_MAJOR_VERSION']}(\.|)#{tkconf['TK_MINOR_VERSION']}.*)\.[^.]*$/
-        #puts "check #{file} #{$1} #{tkfunc} #{dir}"
-        # find_library($1, tkfunc, dir)
-        tklibs = append_library(tcllibs, $1)
-        $LIBPATH = libpath | [dir]
-        try_func(tkfunc, tklibs)
+    end
+  }
+  tclconf['MKMF_PARAMS'] = mkmf_param if tclconf && tcllib_ok
+
+  tklib_ok ||= !tkconf || Dir.glob(File.join(tkdir, tk_glob), File::FNM_CASEFOLD).find{|file|
+    if file =~ tk_regexp
+      libname = $1
+      ext = $2.downcase
+      begin
+        #puts "check #{file} #{$1} #{tkfunc} #{tkdir}"
+        # find_library($1, tkfunc, tkdir)
+        if (tkconf && tkconf["TCL_SHARED_BUILD"] == "0") ||
+            (ext != CONFIG['DLEXT'] && ext == CONFIG['LIBEXT']) || ext == "a"
+          # static link
+          tklibs = " -DSTATIC_BUILD " + file.quote
+
+          # FIX ME: avoid pathname trouble (fail to find) on MinGW.
+          $INCFLAGS << " -I" << File.join(File.dirname(File.dirname(file)),"include") if is_win32?
+        else
+          tklibs = append_library("", libname)
+          #tklibs = append_library("", $1)
+          tklibs = "-L#{tkdir.quote} -Wl,-R#{tkdir.quote} " + tklibs
+
+          # FIX ME: avoid pathname trouble (fail to find) on MinGW.
+          $INCFLAGS << " -I" << File.join(File.dirname(tcldir),"include") if is_win32?
+        end
+
+        tklibs << " " <<  tcllibs if tcllibs
+        tmp_tklibs = tklibs.dup
+        $LIBPATH = libpath | [tkdir]
+        try_func(tkfunc, tklibs, ["tcl.h", "tk.h"]) ||
+          ( try_func(tkfunc, tklibs << " " << tkconf['TK_LIBS'], ["tcl.h", "tk.h"]) if tkconf['TK_LIBS'] ) ||
+          ( try_func(tkfunc, (tklibs = tmp_tklibs.dup) << " " << tkconf['TK_XLIBSW'], ["tcl.h", "tk.h"]) if tkconf['TK_XLIBSW'] ) ||
+          ( try_func(tkfunc, tklibs << " " << tkconf['TK_LIBS'], ["tcl.h", "tk.h"]) if tkconf['TK_LIBS'] )
+
+      ensure
+        mkmf_param = {
+          'PATH' => file,
+          'LIBNAME' => libname,
+          'libs' => tklibs.dup,
+          'INCFLAGS' => $INCFLAGS.dup,
+          'LIBPATH' => $LIBPATH.dup,
+        }
+        $LIBPATH = libpath.dup
+        $libs = libs_param.dup
       end
-    }
-  ensure
-    $LIBPATH = libpath
-  end
+    end
+  }
 
+  $INCFLAGS = incflags.dup
+  tkconf['MKMF_PARAMS'] = mkmf_param if tkconf && tklib_ok
+
   [tcllib_ok, tklib_ok]
 end
 
@@ -559,6 +694,16 @@
   paths.compact!
   if paths.empty?
     config_dir = get_tclConfig_dirs
+  elsif paths.length == 1 && !paths[0][0] && !paths[0][1]
+    config_dir = get_tclConfig_dirs.map{|dir|
+      if dir.kind_of? Array
+        [ (paths[0][0] == false)? nil: dir[0],
+          (paths[0][1] == false)? nil: dir[1] ]
+      else
+        [ (paths[0][0] == false)? nil: dir,
+          (paths[0][1] == false)? nil: dir ]
+      end
+    }
   else
     # fixed tclConfig
     config_dir = []
@@ -573,12 +718,28 @@
   end
 
   tclver, tkver = TkLib_Config['tcltkversion']
+  if tclver && tclver =~ /^\D*(\d)\.?(\d)?/  # ignore PATCH_LEVEL
+    tclver_major = $1
+    tclver_minor = $2
+  else
+    tclver_major = nil
+    tclver_minor = nil
+  end
+  if tkver && tkver =~ /^\D*(\d)\.?(\d)?/  # ignore PATCH_LEVEL
+    tkver_major = $1
+    tkver_minor = $2
+  else
+    tkver_major = nil
+    tkver_minor = nil
+  end
+
   conf = nil
 
   config_dir.uniq!
   config_dir.map{|dir|
     if dir.kind_of? Array
-      [dir[0].strip.chomp('/'), dir[1].strip.chomp('/')]
+      [ (dir[0])? dir[0].strip.chomp('/'): nil,
+        (dir[1])? dir[1].strip.chomp('/'): nil ]
     else
       dir.strip.chomp('/')
     end
@@ -593,32 +754,51 @@
 
     tails = ['Config-shared.sh', 'config-shared.sh', 'Config.sh', 'config.sh']
 
-    if File.file?(tcldir)
-      tclcfg_files = [tcldir] * tails.length
+    if tcldir
+      if File.file?(tcldir)
+        tclcfg_files = [tcldir] * tails.length
+      else
+        tclcfg_files = tails.map{|f| File.join(tcldir, 'tcl' << f)}
+      end
     else
-      tclcfg_files = tails.map{|f| File.join(tcldir, 'tcl' << f)}
+      tclcfg_files = [nil] * tails.length
     end
 
-    if File.file?(tkdir)
-      tkcfg_files = [tkdir] * tails.length
+    if tkdir
+      if File.file?(tkdir)
+        tkcfg_files = [tkdir] * tails.length
+      else
+        tkcfg_files = tails.map{|f| File.join(tkdir, 'tk' << f)}
+      end
     else
-      tkcfg_files = tails.map{|f| File.join(tkdir, 'tk' << f)}
+      tkcfg_files = [nil] * tails.length
     end
 
-    tclcfg_files.zip(tkcfg_files).uniq.each{|tclpath, tkpath|
-      next if !File.exist?(tclpath) || !File.exist?(tkpath)
+    tclcfg_files.zip(tkcfg_files).map{|tclpath, tkpath|
+      [ (tclpath && File.exist?(tclpath))? File.expand_path(tclpath): tclpath,
+        (tkpath && File.exist?(tkpath))? File.expand_path(tkpath): tkpath ]
+    }.uniq.each{|tclpath, tkpath|
+      next if tclpath && !File.exist?(tclpath)
+      next if tkpath && !File.exist?(tkpath)
 
       #  (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]