Navigation Menu

Skip to content

Commit

Permalink
* ext/dbm/extconf.rb: check DBM_SUFFIX for Mac OS X.
Browse files Browse the repository at this point in the history
  Its ndbm.h doesn't include db.h.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
akr committed Feb 21, 2012
1 parent 80a6b14 commit 8963f50
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
Wed Feb 22 06:12:15 2012 Tanaka Akira <akr@fsij.org>

* ext/dbm/extconf.rb: check DBM_SUFFIX for Mac OS X.
Its ndbm.h doesn't include db.h.

Wed Feb 22 06:02:42 2012 Tanaka Akira <akr@fsij.org>

* ext/dbm/dbm.c (fdbm_initialize): disable Berkeley DB error messages.
Expand Down
4 changes: 2 additions & 2 deletions ext/dbm/dbm.c
Expand Up @@ -197,7 +197,7 @@ fdbm_initialize(int argc, VALUE *argv, VALUE obj)
rb_fd_fix_cloexec(dbm_dirfno(dbm));
#endif

#if defined(_DB_H_) && defined(HAVE_TYPE_DBC)
#if defined(RUBYDBM_DB_HEADER) && 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);
Expand Down Expand Up @@ -1101,7 +1101,7 @@ Init_dbm(void)
# else
rb_define_const(rb_cDBM, "VERSION", rb_str_new2("GDBM (unknown)"));
# endif
#elif defined(_DB_H_)
#elif defined(RUBYDBM_DB_HEADER)
# 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(NULL, NULL, NULL)));
Expand Down
7 changes: 7 additions & 0 deletions ext/dbm/extconf.rb
Expand Up @@ -152,6 +152,9 @@ def headers.db_check2(db, hdr)
# it defines _DB_H_.
have_db_header = have_macro('_DB_H_', hdr, hsearch)

# Mac OS X uses Berkeley DB 1 but ndbm.h doesn't include db.h.
have_db_header |= have_macro('DBM_SUFFIX', hdr, hsearch)

# Old GDBM's ndbm.h, until 1.8.3, defines dbm_clearerr as a macro which
# expands to no tokens.
have_gdbm_header1 = have_empty_macro_dbm_clearerr(hdr, hsearch)
Expand All @@ -172,6 +175,10 @@ def headers.db_check2(db, hdr)
return false
end

if have_db_header
$defs.push('-DRUBYDBM_DB_HEADER')
end

have_gdbm_header = have_gdbm_header1 | have_gdbm_header2
if have_gdbm_header
$defs.push('-DRUBYDBM_GDBM_HEADER')
Expand Down

0 comments on commit 8963f50

Please sign in to comment.