summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-21 21:04:04 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-21 21:04:04 +0000
commiteac1d9cfcad5d2d56951e540eb7023eccf7a3593 (patch)
tree3b35155577e76e5b82b25410f5e11bb0c9a79f0c /ext
parentca9b0f56fc25a2b98c0646014f5fb352319e8070 (diff)
* ext/dbm/dbm.c (fdbm_initialize): disable Berkeley DB error messages.
* ext/dbm/extconf.rb: check DBC type for above. [ruby-dev:45269] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/dbm/dbm.c6
-rw-r--r--ext/dbm/extconf.rb5
2 files changed, 11 insertions, 0 deletions
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index d6d1f49..30f0d9d 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -196,6 +196,12 @@ fdbm_initialize(int argc, VALUE *argv, VALUE obj)
#if defined(HAVE_DBM_DIRFNO)
rb_fd_fix_cloexec(dbm_dirfno(dbm));
#endif
+
+#if defined(_DB_H_) && defined(HAVE_TYPE_DBC)
+ /* Disable Berkeley DB error messages such as:
+ * DB->put: attempt to modify a read-only database */
+ ((DBC*)dbm)->dbp->set_errfile(((DBC*)dbm)->dbp, NULL);
+#endif
}
if (!dbm) {
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 751fb40..f2bf148 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -222,6 +222,11 @@ def headers.db_check2(db, hdr)
return false
end
+ # DBC type is required to disable error messages by Berkeley DB 2 or later.
+ if have_db_header
+ have_type("DBC", hdr, hsearch)
+ end
+
if hsearch
$defs << hsearch
@defs = hsearch