ruby-changes:22698
From: akr <ko1@a...>
Date: Wed, 22 Feb 2012 21:45:19 +0900 (JST)
Subject: [ruby-changes:22698] akr:r34747 (trunk): * ext/curses/extconf.rb: refactored.
akr 2012-02-22 21:45:04 +0900 (Wed, 22 Feb 2012) New Revision: 34747 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34747 Log: * ext/curses/extconf.rb: refactored. Modified files: trunk/ChangeLog trunk/ext/curses/extconf.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 34746) +++ ChangeLog (revision 34747) @@ -1,3 +1,7 @@ +Wed Feb 22 21:44:29 2012 Tanaka Akira <akr@f...> + + * ext/curses/extconf.rb: refactored. + Wed Feb 22 20:42:28 2012 Tanaka Akira <akr@f...> * ext/curses/extconf.rb: try to distinguish curses_version is a Index: ext/curses/extconf.rb =================================================================== --- ext/curses/extconf.rb (revision 34746) +++ ext/curses/extconf.rb (revision 34747) @@ -1,28 +1,26 @@ require 'mkmf' -def transact +def have_all(*args) old_libs = $libs.dup old_defs = $defs.dup - result = yield - if !result - $libs = old_libs - $defs = old_defs + result = [] + begin + args.each {|arg| + r = arg.call(*result) + if !r + return nil + end + result << r + } + result + ensure + if result.length != args.length + $libs = old_libs + $defs = old_defs + end end - result end -def check_header_library(hdr, libs) - if !have_header(hdr) - return nil - end - libs.each {|lib| - if have_library(lib, "initscr") - return [hdr, lib] - end - } - nil -end - dir_config('curses') dir_config('ncurses') dir_config('termcap') @@ -37,7 +35,9 @@ ["curses_colr/curses.h", ["cur_colr"]], ["curses.h", ["curses"]], ].each {|hdr, libs| - header_library = transact { check_header_library(hdr, libs) } + header_library = have_all( + lambda { have_header(hdr) && hdr }, + lambda {|h| libs.find {|lib| have_library(lib, "initscr", h) } }) if header_library break; end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/