summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-22 12:45:04 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-22 12:45:04 +0000
commit7c80d15165022a040805001586472fa89dd266d9 (patch)
treef200f4b22b877ebdc02a27f2331168f1a7dcda01 /ext
parentc01d52e8d9e3f1596d3bbbebaa8ea35c330f8763 (diff)
* ext/curses/extconf.rb: refactored.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/curses/extconf.rb38
1 files changed, 19 insertions, 19 deletions
diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb
index 14dfa7d5cb..9b920323c3 100644
--- a/ext/curses/extconf.rb
+++ b/ext/curses/extconf.rb
@@ -1,26 +1,24 @@
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
- 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]
+ 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
- }
- nil
+ end
end
dir_config('curses')
@@ -37,7 +35,9 @@ header_library = nil
["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