summaryrefslogtreecommitdiff
path: root/ext/dbm
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-06 10:21:12 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-06 10:21:12 +0000
commitbb1875175bd683014008e23cde429d8508d5524e (patch)
tree7235feac43f304607518683bdc582b9e1dd7d175 /ext/dbm
parent1ff15071d05f343206318b6f06b45c43dec814f1 (diff)
* ext/dbm/dbm.c: use db_version() instead of DB_VERSION_STRING for
detect runtime Berkeley DB version. use dpversion instead of _QDBM_VERSION for detect runtime QDBM [ruby-dev:44948] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dbm')
-rw-r--r--ext/dbm/dbm.c12
-rw-r--r--ext/dbm/extconf.rb7
2 files changed, 12 insertions, 7 deletions
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index 221c6739e7..e4f646ec45 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -1076,21 +1076,21 @@ Init_dbm(void)
*/
rb_define_const(rb_cDBM, "NEWDB", INT2FIX(O_RDWR|O_CREAT|O_TRUNC|RUBY_DBM_RW_BIT));
-#if defined(DB_VERSION_STRING)
+#if defined(HAVE_DB_VERSION)
/* 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(NULL, NULL, NULL)));
#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. */
{
- /* 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(HAVE_DPVERSION)
+ rb_define_const(rb_cDBM, "VERSION", rb_sprintf("QDBM %s", dpversion));
#elif defined(_DB_H_)
rb_define_const(rb_cDBM, "VERSION", rb_str_new2("Berkeley DB (unknown)"));
#else
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 6a4b8c069d..9c4004814e 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -80,12 +80,17 @@ def headers.db_check2(db, hdr)
(db == 'libc' ? have_func('dbm_open("", 0, 0)', hdr, hsearch) :
have_library(db, 'dbm_open("", 0, 0)', hdr, hsearch)) and
have_func('dbm_clearerr((DBM *)0)', hdr, hsearch)
- if /gdbm/ =~ db
+ case db
+ when /\Adb\d?\z/
+ have_func('db_version((int *)0, (int *)0, (int *)0)', hdr, hsearch)
+ when /\Agdbm/
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)
+ when /\Aqdbm\z/
+ have_var("dpversion", hdr, hsearch)
end
if hsearch
$defs << hsearch