mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/dbm/extconf.rb: detect gdbm_version in libgdbm.
* ext/dbm/dbm.c: make DBM::VERSION more informative for gdbm, qdbm and Berkeley DB 1.x. [ruby-dev:44944] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
79bc357902
commit
2f49f5ee0b
3 changed files with 55 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Tue Dec 6 12:30:41 2011 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/dbm/extconf.rb: detect gdbm_version in libgdbm.
|
||||||
|
|
||||||
|
* ext/dbm/dbm.c: make DBM::VERSION more informative for gdbm, qdbm and
|
||||||
|
Berkeley DB 1.x. [ruby-dev:44944]
|
||||||
|
|
||||||
Tue Dec 6 07:26:37 2011 Eric Hodel <drbrain@segment7.net>
|
Tue Dec 6 07:26:37 2011 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
* range.c: Improve documentation for Range. Patch by Chris Zetter.
|
* range.c: Improve documentation for Range. Patch by Chris Zetter.
|
||||||
|
|
|
@ -1076,9 +1076,23 @@ Init_dbm(void)
|
||||||
*/
|
*/
|
||||||
rb_define_const(rb_cDBM, "NEWDB", INT2FIX(O_RDWR|O_CREAT|O_TRUNC|RUBY_DBM_RW_BIT));
|
rb_define_const(rb_cDBM, "NEWDB", INT2FIX(O_RDWR|O_CREAT|O_TRUNC|RUBY_DBM_RW_BIT));
|
||||||
|
|
||||||
#ifdef DB_VERSION_STRING
|
#if defined(DB_VERSION_STRING)
|
||||||
/* The version of the dbm library, if using Berkeley DB */
|
/* The version of the dbm library, if using Berkeley DB */
|
||||||
rb_define_const(rb_cDBM, "VERSION", rb_str_new2(DB_VERSION_STRING));
|
rb_define_const(rb_cDBM, "VERSION", rb_str_new2(DB_VERSION_STRING));
|
||||||
|
#elif defined(HAVE_GDBM_VERSION)
|
||||||
|
/* since gdbm 1.9 */
|
||||||
|
rb_define_const(rb_cDBM, "VERSION", rb_str_new2(gdbm_version));
|
||||||
|
#elif defined(HAVE_LIBVAR_GDBM_VERSION)
|
||||||
|
{
|
||||||
|
/* ndbm.h doesn't declare gdbm_version until gdbm 1.8.3.
|
||||||
|
* See extconf.rb for more information. */
|
||||||
|
extern char *gdbm_version;
|
||||||
|
rb_define_const(rb_cDBM, "VERSION", rb_str_new2(gdbm_version));
|
||||||
|
}
|
||||||
|
#elif defined(_QDBM_VERSION)
|
||||||
|
rb_define_const(rb_cDBM, "VERSION", rb_str_new2("QDBM " _QDBM_VERSION));
|
||||||
|
#elif defined(_DB_H_)
|
||||||
|
rb_define_const(rb_cDBM, "VERSION", rb_str_new2("Berkeley DB (unknown)"));
|
||||||
#else
|
#else
|
||||||
rb_define_const(rb_cDBM, "VERSION", rb_str_new2("unknown"));
|
rb_define_const(rb_cDBM, "VERSION", rb_str_new2("unknown"));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,6 +40,32 @@ def headers.db_check(db, hdr)
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def have_libvar(var, headers = nil, opt = "", &b)
|
||||||
|
checking_for checking_message([*var].compact.join(' '), headers, opt) do
|
||||||
|
try_libvar(var, headers, opt, &b)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def try_libvar(var, headers = nil, opt = "", &b)
|
||||||
|
var, type = *var
|
||||||
|
if try_link(<<"SRC", opt, &b)
|
||||||
|
#{cpp_include(headers)}
|
||||||
|
/*top*/
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
typedef #{type || 'int'} conftest_type;
|
||||||
|
extern conftest_type #{var};
|
||||||
|
conftest_type *conftest_var = &#{var};
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
SRC
|
||||||
|
$defs.push(format("-DHAVE_LIBVAR_%s", var.tr_cpp))
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def headers.db_check2(db, hdr)
|
def headers.db_check2(db, hdr)
|
||||||
hsearch = nil
|
hsearch = nil
|
||||||
|
|
||||||
|
@ -54,6 +80,13 @@ def headers.db_check2(db, hdr)
|
||||||
(db == 'libc' ? have_func('dbm_open("", 0, 0)', hdr, hsearch) :
|
(db == 'libc' ? have_func('dbm_open("", 0, 0)', hdr, hsearch) :
|
||||||
have_library(db, 'dbm_open("", 0, 0)', hdr, hsearch)) and
|
have_library(db, 'dbm_open("", 0, 0)', hdr, hsearch)) and
|
||||||
have_func('dbm_clearerr((DBM *)0)', hdr, hsearch)
|
have_func('dbm_clearerr((DBM *)0)', hdr, hsearch)
|
||||||
|
if /gdbm/ =~ db
|
||||||
|
have_var("gdbm_version", hdr, hsearch)
|
||||||
|
# gdbm_version is not declared by ndbm.h until gdbm 1.8.3.
|
||||||
|
# We can't include ndbm.h and gdbm.h because they both define datum type.
|
||||||
|
# ndbm.h includes gdbm.h and gdbm_version is declared since gdbm 1.9.
|
||||||
|
have_libvar(["gdbm_version", "char *"], hdr, hsearch)
|
||||||
|
end
|
||||||
if hsearch
|
if hsearch
|
||||||
$defs << hsearch
|
$defs << hsearch
|
||||||
@defs = hsearch
|
@defs = hsearch
|
||||||
|
|
Loading…
Reference in a new issue