diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-22 11:44:26 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-22 11:44:26 +0000 |
commit | c01d52e8d9e3f1596d3bbbebaa8ea35c330f8763 (patch) | |
tree | 7566e6c15846290b7476774bd8f92dfb4dc6b497 /ext/curses/extconf.rb | |
parent | fa65fc9aeb5e73b84ce80c4c2c3edaa888362e03 (diff) | |
download | ruby-c01d52e8d9e3f1596d3bbbebaa8ea35c330f8763.tar.gz |
* ext/curses/extconf.rb: try to distinguish curses_version is a
function or variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/curses/extconf.rb')
-rw-r--r-- | ext/curses/extconf.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb index e1499437d0..14dfa7d5cb 100644 --- a/ext/curses/extconf.rb +++ b/ext/curses/extconf.rb @@ -72,5 +72,44 @@ if header_library have_var("TABSIZE", curses) have_var("COLORS", curses) have_var("COLOR_PAIRS", curses) + + # SVR4 curses has a (undocumented) variable char *curses_version. + # ncurses and PDcurses has a function char *curses_version(). + # Note that the original BSD curses doesn't provide version information. + + prolog = cpp_include(curses) + if checking_for(checking_message('function curses_version', curses)) { + try_run(<<-"End") + #{prolog} + int main(int argc, char *argv[]) + { + curses_version(); + return EXIT_SUCCESS; + } + End + } + $defs << '-DHAVE_FUNC_CURSES_VERSION' + end + + if checking_for(checking_message('variable curses_version', curses)) { + try_run(<<-"End") + #{prolog} + extern char *curses_version; + int main(int argc, char *argv[]) + { + int i = 0; + for (i = 0; i < 100; i++) { + if (curses_version[i] == 0) + return 0 < i ? EXIT_SUCCESS : EXIT_FAILURE; + if (curses_version[i] & 0x80) + return EXIT_FAILURE; + } + return EXIT_FAILURE; + } + End + } + $defs << '-DHAVE_VAR_CURSES_VERSION' + end + create_makefile("curses") end |