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

ruby-changes:42689

From: nobu <ko1@a...>
Date: Mon, 25 Apr 2016 16:34:20 +0900 (JST)
Subject: [ruby-changes:42689] nobu:r54763 (trunk): tk/extconf.rb: refactor

nobu	2016-04-25 17:30:56 +0900 (Mon, 25 Apr 2016)

  New Revision: 54763

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54763

  Log:
    tk/extconf.rb: refactor
    
    * ext/tk/extconf.rb (collect_tcltk_defs): split by -D at the
      beginning or preceded by a space.  exclude empty strings from
      $defs.
    
    * ext/tk/extconf.rb: test if value is set and has non-blank by
      matching /\S/ at once.

  Modified files:
    trunk/ext/tk/extconf.rb
Index: ext/tk/extconf.rb
===================================================================
--- ext/tk/extconf.rb	(revision 54762)
+++ ext/tk/extconf.rb	(revision 54763)
@@ -371,7 +371,7 @@ def collect_tcltk_defs(tcl_defs_str, tk_ https://github.com/ruby/ruby/blob/trunk/ext/tk/extconf.rb#L371
   end
 
   if tcl_defs_str
-    tcl_defs = tcl_defs_str.split(/ ?-D/).map{|s|
+    tcl_defs = tcl_defs_str.split(/(?:\A|\s)\s*-D/).map{|s|
       s =~ /^([^=]+)(.*)$/
       [$1, $2]
     }
@@ -380,7 +380,7 @@ def collect_tcltk_defs(tcl_defs_str, tk_ https://github.com/ruby/ruby/blob/trunk/ext/tk/extconf.rb#L380
   end
 
   if tk_defs_str
-    tk_defs = tk_defs_str.split(/ ?-D/).map{|s|
+    tk_defs = tk_defs_str.split(/(?:\A|\s)\s*-D/).map{|s|
       s =~ /^([^=]+)(.*)$/
       [$1, $2]
     }
@@ -396,7 +396,7 @@ def collect_tcltk_defs(tcl_defs_str, tk_ https://github.com/ruby/ruby/blob/trunk/ext/tk/extconf.rb#L396
           vtcl != vtk )
   }
 
-  defs.map{|ary| s = ary.join(''); (s.strip.empty?)? "": "-D" << s}
+  defs.map{|ary| /\S/ =~ (s = ary.join('')) and "-D" << s.strip}.compact
 end
 
 def parse_tclConfig(file)
@@ -1609,9 +1609,8 @@ def search_X_libraries https://github.com/ruby/ruby/blob/trunk/ext/tk/extconf.rb#L1609
   use_tkConfig = false
   if TkConfig_Info['config_file_path']
     # use definitions on tkConfig.sh
-    if (TkConfig_Info['TK_XINCLUDES'] &&
-        !TkConfig_Info['TK_XINCLUDES'].strip.empty?) ||
-        (TkConfig_Info['TK_XLIBSW'] && !TkConfig_Info['TK_XLIBSW'].strip.empty?)
+    if (/\S/ =~ TkConfig_Info['TK_XINCLUDES'] ||
+        /\S/ =~ TkConfig_Info['TK_XLIBSW'])
       use_tkConfig = true
       #use_X = true && with_config("X11", ! is_win32?)
       use_X = with_config("X11", true)
@@ -1624,8 +1623,7 @@ def search_X_libraries https://github.com/ruby/ruby/blob/trunk/ext/tk/extconf.rb#L1623
     use_X = with_config("X11", !(is_win32? || TkLib_Config["tcltk-framework"]))
   end
 
-  if TkConfig_Info['TK_XINCLUDES'] &&
-      !TkConfig_Info['TK_XINCLUDES'].strip.empty?
+  if /\S/ =~ TkConfig_Info['TK_XINCLUDES']
     ($INCFLAGS ||= "") << " " << TkConfig_Info['TK_XINCLUDES'].strip
   end
 
@@ -1636,7 +1634,7 @@ def search_X_libraries https://github.com/ruby/ruby/blob/trunk/ext/tk/extconf.rb#L1634
     unless find_X11(x11_ldir2, x11_ldir)
       puts("Can't find X11 libraries. ")
       if use_tkConfig &&
-          TkConfig_Info['TK_XLIBSW'] && !TkConfig_Info['TK_XLIBSW'].strip.empty?
+          /\S/ =~ TkConfig_Info['TK_XLIBSW']
         puts("But, try to use TK_XLIBSW information (believe tkConfig.sh).")
         ($libs ||= "") << " " << TkConfig_Info['TK_XLIBSW'] << " "
       else
@@ -1919,9 +1917,8 @@ TkLib_Config["space-on-tk-libpath"] = https://github.com/ruby/ruby/blob/trunk/ext/tk/extconf.rb#L1917
 
 # enable Tcl/Tk stubs?
 =begin
-if TclConfig_Info['TCL_STUB_LIB_SPEC'] && TkConfig_Info['TK_STUB_LIB_SPEC'] &&
-    !TclConfig_Info['TCL_STUB_LIB_SPEC'].strip.empty? &&
-    !TkConfig_Info['TK_STUB_LIB_SPEC'].strip.empty?
+if /\S/ =~ TclConfig_Info['TCL_STUB_LIB_SPEC'] &&
+   /\S/ =~ TkConfig_Info['TK_STUB_LIB_SPEC']
   stubs = true
   unless (st = enable_config("tcltk-stubs")).nil?
     stubs &&= st
@@ -2027,16 +2024,14 @@ if TkLib_Config["tcltk-framework"] https://github.com/ruby/ruby/blob/trunk/ext/tk/extconf.rb#L2024
     libs << ' ' << TclConfig_Info['TCL_LIBS']
     if stubs
       if TkLib_Config["tcl-build-dir"] &&
-          TclConfig_Info['TCL_BUILD_STUB_LIB_SPEC'] &&
-          !TclConfig_Info['TCL_BUILD_STUB_LIB_SPEC'].strip.empty?
+          /\S/ =~ TclConfig_Info['TCL_BUILD_STUB_LIB_SPEC']
         libs << ' ' << TclConfig_Info['TCL_BUILD_STUB_LIB_SPEC']
       else
         libs << ' ' << TclConfig_Info['TCL_STUB_LIB_SPEC']
       end
     else
       if TkLib_Config["tcl-build-dir"] &&
-          TclConfig_Info['TCL_BUILD_LIB_SPEC'] &&
-          !TclConfig_Info['TCL_BUILD_LIB_SPEC'].strip.empty?
+          /\S/ =~ TclConfig_Info['TCL_BUILD_LIB_SPEC']
         libs << ' ' << TclConfig_Info['TCL_BUILD_LIB_SPEC']
       else
         libs << ' ' << TclConfig_Info['TCL_LIB_SPEC']
@@ -2052,16 +2047,14 @@ if TkLib_Config["tcltk-framework"] https://github.com/ruby/ruby/blob/trunk/ext/tk/extconf.rb#L2047
     libs << ' ' << TkConfig_Info['TK_LIBS']
     if stubs
       if TkLib_Config["tk-build-dir"] &&
-          TclConfig_Info['TK_BUILD_STUB_LIB_SPEC'] &&
-          !TclConfig_Info['TK_BUILD_STUB_LIB_SPEC'].strip.empty?
+          /\S/ =~ TclConfig_Info['TK_BUILD_STUB_LIB_SPEC']
         libs << ' ' << TkConfig_Info['TK_BUILD_STUB_LIB_SPEC']
       else
         libs << ' ' << TkConfig_Info['TK_STUB_LIB_SPEC']
       end
     else
       if TkLib_Config["tk-build-dir"] &&
-          TclConfig_Info['TK_BUILD_LIB_SPEC'] &&
-          !TclConfig_Info['TK_BUILD_LIB_SPEC'].strip.empty?
+          /\S/ =~ TclConfig_Info['TK_BUILD_LIB_SPEC']
         libs << ' ' << TkConfig_Info['TK_BUILD_LIB_SPEC']
       else
         libs << ' ' << TkConfig_Info['TK_LIB_SPEC']

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

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