[Bug #3385] ext/dbm: accept various version of db

Bug #3385: ext/dbm: accept various version of db
http://redmine.ruby-lang.org/issues/show/3385

e$B5/I<<Te(B: Takahiro K.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
ruby -v: ruby 1.9.2dev (2010-05-31 revision 28117) [i486-netbsdelf]

ext/dbe$B$Ne(Bextconf.rbe$B$K!"MM!9$J%P!<%8%g%s$Ne(BBerkley
DBe$B$rG’<1$5$;$k$?$a$N%Q%C%A$G$9!#e(B

— ext/dbm/extconf.rb.orig 2009-10-02 10:45:39.000000000 +0000
+++ ext/dbm/extconf.rb
@@ -5,13 +5,16 @@ dir_config(“dbm”)
if dblib = with_config(“dbm-type”, nil)
dblib = dblib.split(/[ ,]+/)
else

  • dblib = %w(db db2 db1 dbm gdbm gdbm_compat qdbm)
  • dblib = %w(db db2 db1 db5 db4 db3 dbm gdbm gdbm_compat qdbm)
    end

headers = {
“db” => [“db.h”],
“db1” => [“db1/ndbm.h”, “db1.h”, “ndbm.h”],
“db2” => [“db2/db.h”, “db2.h”, “db.h”],

  • “db3” => [“db3/db.h”, “db3.h”, “db.h”],

  • “db4” => [“db4/db.h”, “db4.h”, “db.h”],

  • “db5” => [“db5/db.h”, “db5.h”, “db.h”],
    “dbm” => [“ndbm.h”],
    “gdbm” => [“gdbm-ndbm.h”, “ndbm.h”],
    “gdbm_compat” => [“gdbm-ndbm.h”, “ndbm.h”],
    @@ -24,7 +27,7 @@ def headers.db_check(db)
    hsearch = nil

    case db

  • when /^db2?$/
  • when /^db[2-5]?$/
    db_prefix = “__db_n”
    hsearch = "-DDB_DBM_HSEARCH "
    when “gdbm”
    @@ -36,7 +39,8 @@ def headers.db_check(db)
    db_prefix ||= “”

    if (have_library(db, db_prefix+“dbm_open”) ||
    have_func(db_prefix+“dbm_open”)) and

  •  hdr = self.fetch(db, ["ndbm.h"]).find {|h| have_type("DBM", h, 
    

hsearch)}

  •  hdr = self.fetch(db, ["ndbm.h"]).find {|h| have_type("DBM", h, 
    

hsearch)} or

  •  hdr = self.fetch(db, ["ndbm.h"]).find {|h| have_type("DBM", 
    

[“db.h”, h], hsearch)}
have_func(db_prefix+“dbm_clearerr”) unless have_gdbm
$defs << hsearch if hsearch
$defs << ‘-DDBM_HDR="<’+hdr+’>"’

e$B%A%1%C%He(B #3385 e$B$,99?7$5$l$^$7$?!#e(B (by Yusuke E.)

e$B1sF#$G$9!#e(B

ext/dbe$B$Ne(Bextconf.rbe$B$K!"MM!9$J%P!<%8%g%s$Ne(BBerkley DBe$B$rG’<1$5$;$k$?$a$N%Q%C%A$G$9!#e(B

e$B3NG’$G$9$,!"%P!<%8%g%se(B 3 e$B$+$ie(B 5
e$B$rG’<1$5$;$k$h$&$K$J$C$?$N$G$9$h$M!#e(B
e$B<B:]$K$=$l$>$l$N%P!<%8%g%s$G%S%k%I$7$F!“e(Btest/dbm/
e$B$,%Q%9$9$k$3$H$re(B
e$B3NG’$7$FD:$$$?$H$$$&$3$H$G$7$g$&$+!#e(B
e$B$=$&$$$&$3$H$G$”$l$P!"[email protected]$5$s$r?.$8$F<h$j9~$b$&$H;W$$$^$9!#e(B

e$B$"$H!"e(B

  • dblib = %w(db db2 db1 db5 db4 db3 dbm gdbm gdbm_compat qdbm)

e$B$H$$$&IT;W5D$J=gHV$G%A%’%C%/$9$k$3$H$K0UL#$O$"$k$G$7$g$&$+!#e(B


Yusuke E. [email protected]

http://redmine.ruby-lang.org/issues/show/3385

e$B%A%1%C%He(B #3385 e$B$,99?7$5$l$^$7$?!#e(B (by Takahiro K.)

e$B3NG’$G$9$,!"%P!<%8%g%se(B 3 e$B$+$ie(B 5 e$B$rG’<1$5$;$k$h$&$K$J$C$?$N$G$9$h$M!#e(B
e$B$=$&$G$9!#e(B

e$B<B:]$K$=$l$>$l$N%P!<%8%g%s$G%S%k%I$7$F!"e(Btest/dbm/ e$B$,%Q%9$9$k$3$H$re(B
e$B3NG’$7$FD:$$$?$H$$$&$3$H$G$7$g$&$+!#e(B
e$B%F%9%H$^$G$O$7$F$$$^$;$s!#[email protected]!"e(Bdbme$B$N8_49%i%$%V%i%j$H$7$F3F%P!<%8%g%s$Ne(BBerkeley
DBe$B$r;H$&J,$K!"e(B
e$B$=$l$[$ILdBj$,=P$F$/$k$H$b;W$($^$;$s!#e(B

e$B$=$&$$$&$3$H$G$"$l$P!"[email protected]$5$s$r?.$8$F<h$j9~$b$&$H;W$$$^$9!#e(B
e$B$H!"$$$&$o$1$G?.$8$F$O%@%a$G$9!#e(B;-)

  • dblib = %w(db db2 db1 db5 db4 db3 dbm gdbm gdbm_compat qdbm)

e$B$H$$$&IT;W5D$J=gHV$G%A%’%C%/$9$k$3$H$K0UL#$O$"$k$G$7$g$&$+!#e(B
e$B?7$7$$%j%j!<%9$K$D$$$F$O?7$7$$$b$N$rM%@h!"$G$b%Y!<%9%7%9%F%`$KB8:_$7$F$$$ke(Bdbe$B$,$"$l$P$=$l$G:Q$^$;$?$$!"$H$$$C$?DxEY$N0U?^$G$9$,!“e(Bdb2e$B$de(Bdb1e$B$NJU$j$O85$rB:[email protected]$1$J$N$G?<$$0UL#$O$”$j$^$;$s!#e(B


http://redmine.ruby-lang.org/issues/show/3385

e$B%A%1%C%He(B #3385 e$B$,99?7$5$l$^$7$?!#e(B (by Takahiro K.)

Berkeley DB e$B$Oe(B API [email protected]$H$+$K$A$c$s$H5$$r;H$C$F$$$kN)GI$Je(B
e$B%W%m%8%’%/%H$J$s$G$9$+$M!#e(BOpenSSL e$B$H$+e(B Ruby e$B$H$+8+$F$k$H$I$&$be(B
e$B5?$$?<$/$J$C$F$7$^$$$^$9!#e(B
Berkley
DBe$B$H$7$F$Oe(B4.6e$B$He(B4.7e$B$GHs8_49$,$"$C$F!"e(B/usr/pkgsrc/databased/db46
e$B$H$+$,B8:_$7$^$9!#e(B

e$B$"$/$^$G$b!Ve(Bdbme$B8_49$NItJ,[email protected]$1$K8B$l$P!"e(Bdbme$B<+BN$,$=$s$J$KHs8_49$,=P$F$/$k$H$3$m$O9M$($K$/$/!"e(B
e$BF10l$N%P!<%8%g%s$Ne(BBerklery
DBe$B$rAj<j$K$7$F$$$k8B$j$OLdBj$O=P$F$3$J$$$H;W$&$o$1$G$9!#e(B

e$B0lJ}$G!“e(BRubye$B$N9T$&%F%9%H$G=P$F$3$J$$$G$”$m$&ItJ,$H$7$F$O!"<B:]$K:[email protected]$7$?e(B
foo.db e$B$N%U%!%$%k$Ne(B
e$BFbMF$,0[$J$ke(BBerkley
DBe$B$N4V$G8_49$,$"$k$N$+$H$$$&ItJ,$b$"$k$G$7$g$&!#e(B


http://redmine.ruby-lang.org/issues/show/3385

e$B%A%1%C%He(B #3385 e$B$,99?7$5$l$^$7$?!#e(B (by Yusuke E.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B

e$B1sF#$G$9!#e(B

e$B<B:]$K$=$l$>$l$N%P!<%8%g%s$G%S%k%I$7$F!"e(Btest/dbm/ e$B$,%Q%9$9$k$3$H$re(B
e$B3NG’$7$FD:$$$?$H$$$&$3$H$G$7$g$&$+!#e(B
e$B%F%9%H$^$G$O$7$F$$$^$;$s!#[email protected]!"e(Bdbme$B$N8_49%i%$%V%i%j$H$7$F3F%P!<%8%g%s$Ne(BBerkeley DBe$B$r;H$&J,$K!"e(B
e$B$=$l$[$ILdBj$,=P$F$/$k$H$b;W$($^$;$s!#e(B

Berkeley DB e$B$Oe(B API
[email protected]$H$+$K$A$c$s$H5$$r;H$C$F$$$kN)GI$Je(B
e$B%W%m%8%’%/%H$J$s$G$9$+$M!#e(BOpenSSL e$B$H$+e(B Ruby
e$B$H$+8+$F$k$H$I$&$be(B
e$B5?$$?<$/$J$C$F$7$^$$$^$9!#e(B

e$B$H$j$"$($:!“e(Btrunk e$B$K<h$j9~$$^$7$?!#$"$j$,$H$&$4$6$$$^$7$?!#e(B
e$B$3$N%A%1%C%H$Oe(B Bug e$B$H$$$&$h$je(B Feature
e$B$J5$$b$9$k$N$G!"e(Bruby_1_9_2
e$B$X$N<h$j9~$
$K$O$”$^$j>h$j5$$G$"$j$^$;$s!#e(B


Yusuke E. [email protected]

http://redmine.ruby-lang.org/issues/show/3385

2010$BG/(B6$B7n(B3$BF|(B23:38 Takahiro K. [email protected]:

Bug #3385: ext/dbm: accept various version of db
http://redmine.ruby-lang.org/issues/show/3385

$B5/I<<T(B: Takahiro K.
$B%9%F!<%?%9(B: Open, $BM%@hEY(B: Normal
ruby -v: ruby 1.9.2dev (2010-05-31 revision 28117) [i486-netbsdelf]

ext/db$B$N(Bextconf.rb$B$K!"MM!9$J%P!<%8%g%s$N(BBerkley
DB$B$rG’<1$5$;$k$?$a$N%Q%C%A$G$9!#(B

$B$+$J$jA0$NOC$G$9$,!"5?Ld$,$o$$$?$N$G65$($F$/[email protected]$5$$!#(B

— ext/dbm/extconf.rb.orig 2009-10-02 10:45:39.000000000 +0000
+++ ext/dbm/extconf.rb

@@ -36,7 +39,8 @@ def headers.db_check(db)
db_prefix ||= “”

if (have_library(db, db_prefix+“dbm_open”) || have_func(db_prefix+“dbm_open”))
and

  •  hdr = self.fetch(db, ["ndbm.h"]).find {|h| have_type("DBM", h, hsearch)}
    
  •  hdr = self.fetch(db, ["ndbm.h"]).find {|h| have_type("DBM", h, hsearch)} 
    

or

  •  hdr = self.fetch(db, ["ndbm.h"]).find {|h| have_type("DBM", ["db.h", h], 
    

hsearch)}

have_func(db_prefix+"dbm_clearerr") unless have_gdbm
$defs << hsearch if hsearch
$defs << '-DDBM_HDR="<'+hdr+'>"'

$B$3$3$NItJ,$G$9$,!"(Bhave_type(“dbm”, [“db.h”, h], hsearch)} $B$r(B
$B2C$($F$$$k$N$O$J$s$G$G$7$g$&(B?

$B$3$3$G(B h $B$O(B “db2/db.h”, “db2.h”, “db.h”
$B$H$$$C$?%X%C%@%U%#%k$NL>A0$,(B
$BF~$C$F$$$k$N$G!"$=$l$K(B “db.h” $B$r9g$o$;$k$H(B

“db.h” $B$H(B “db2/db.h” $B$rN>J}(B include $B$9$k$H$+!"(B
“db.h” $B$H(B 2$B2s(B include
$B$9$k$H$+$$$&$3$H$r%F%9%H$9$k$3$H$K$J$j$^$9!#(B

$B<B:]!"(BBerkeley DB $B$,F~$C$F$$$J$$4D6-$G(B (Ruby 1.9.3 $B$r(B)
$B$r;n$9$H!"(B

1: #include “ruby.h”
2:
3: #include <db.h>
4: #include <db.h>
5:
6: /top/
7: typedef DBM conftest_type;
8: int conftestval[sizeof(conftest_type)?1:-1];

$B$H$+!"(B

/* begin /
1: #include “ruby.h”
2:
3: #include <db.h>
4: #include <db2/db.h>
5:
6: /top/
7: typedef DBM conftest_type;
8: int conftestval[sizeof(conftest_type)?1:-1];
/
end */

$B$H$$$C$?5-O?$,(B ext/dbm/mkmf.log $B$K;D$C$F$$$^$9!#(B

$B$I$&$b4qL/$K;W$($k$s$G$9$,!"$I$&$$$&0U?^$J$s$G$7$g$&(B?

2011$BG/(B11$B7n(B12$BF|(B8:14 Tanaka A. [email protected]:

$B$3$3$NItJ,$G$9$,!"(Bhave_type(“dbm”, [“db.h”, h], hsearch)} $B$r(B
$B2C$($F$$$k$N$O$J$s$G$G$7$g$&(B?

$BC5$7$?$H$3$m!"(Bpkgsrc $B$N(B

Both db.h and ndbm.1 must be included to use DBM. Use both headers
in extconf.rb to check the availability of DBM. This makes the
package
build on Darwin.

http://pkgsrc.se/[email protected]

$B$H$$$&$N$,85$N$h$&$G!"(BDarwin $B$G$O(B db.h $B$H(B ndbm.h
$B$NN>J}$r(B include $B$7$J$$$H(B
DBM $B$,;H$($J$$$H$$$&OC$N$h$&$G$9!#(B

$B$7$+$7!"$I$&$b$3$l$O?.$8Fq$$$G$9!#(B
$B$3$N%Q%C%A$O(B extconf.rb $B$G(B db.h $B$r;H$C$F(B DBM
$B$H$$$&7?$r3NG’$9$k$b$N$G$9$,!"(B
dbm.c $B$G$O(B db.h $B$r(B include $B$9$k$h$&$K$O$J$C$F$$$^$;$s!#(B
$B$=$7$F!"$=$l$G$b(B dbm $B$,%3%s%Q%$%k$G$-$k0J>e(B DBM
$B$H$$$&7?$O;H$($F$$$k$O$:$G$9!#(B

$B$3$NItJ,$r30$7$F8=:_$N(B Darwin $B$G$bLdBj$J$$$h$&$J$i!"(B
$B30$7$F$7$^$$$?$$$s$G$9$,!"$I$&$G$9$+$M!#(B
$B$I$J$?$+;[email protected]$1$J$$$G$7$g$&$+!#(B

1.9.3 $B$J$i0J2<$N%Q%C%A$G30$l$^$9!#(B

% svn diff --diff-cmd diff -x ‘-u -p’
Index: ext/dbm/extconf.rb

— ext/dbm/extconf.rb (revision 33774)
+++ ext/dbm/extconf.rb (working copy)
@@ -39,8 +39,7 @@ def headers.db_check(db)
db_prefix ||= “”

if (have_library(db, db_prefix+“dbm_open”) ||
have_func(db_prefix+“dbm_open”)) and

  •  hdr = self.fetch(db, ["ndbm.h"]).find {|h| have_type("DBM", h,
    

hsearch)} or

  •  hdr = self.fetch(db, ["ndbm.h"]).find {|h| have_type("DBM",
    

[“db.h”, h], hsearch)}

  •  hdr = self.fetch(db, ["ndbm.h"]).find {|h| have_type("DBM", h, 
    

hsearch)}
have_func(db_prefix+“dbm_clearerr”) unless have_gdbm
$defs << hsearch if hsearch
$defs << ‘-DDBM_HDR="<’+hdr+’>"’

trunk
$B$O$$$m$$$m$HJQ$o$C$F$$$^$9$,!"0J2<$N%Q%C%A$GAjEv$9$kItJ,$r30$;$^$9!#(B

% svn diff --diff-cmd diff -x ‘-u -p’
Index: ext/dbm/extconf.rb

— ext/dbm/extconf.rb (revision 33774)
+++ ext/dbm/extconf.rb (working copy)
@@ -50,7 +50,7 @@ def headers.db_check2(db, hdr)
have_library(“gdbm”) or return false
end

  • if (have_type(“DBM”, hdr, hsearch) || have_type(“DBM”, [“db.h”,
    hdr], hsearch)) and
  • if have_type(“DBM”, hdr, hsearch) and
    (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)

2011$BG/(B11$B7n(B16$BF|(B9:55 Tanaka A. [email protected]:

$B$3$NItJ,$r30$7$F8=:_$N(B Darwin $B$G$bLdBj$J$$$h$&$J$i!"(B
$B30$7$F$7$^$$$?$$$s$G$9$,!"$I$&$G$9$+$M!#(B
$B$I$J$?$+;[email protected]$1$J$$$G$7$g$&$+!#(B

Lion$B$G$OLdBj$J$/DL$k$h$&$G$9!#$b$&$$$l$A$c$C$F!"C/$+$,(B
[email protected]$C$F$+$i9M$($k$G$$$$$s$8$c$J$$$G$7$g$&$+!#(B
2.0$B$G$k$3$m$K$O(BSnow Leopard
$B%5%]!<%H$7$J$/$F$bE$i$l$J$$M=46$,$9$k$7(B

2011$BG/(B11$B7n(B17$BF|(B12:17 KOSAKI Motohiro
[email protected]:

Lion$B$G$OLdBj$J$/DL$k$h$&$G$9!#$b$&$$$l$A$c$C$F!"C/$+$,(B
[email protected]$C$F$+$i9M$($k$G$$$$$s$8$c$J$$$G$7$g$&$+!#(B
2.0$B$G$k$3$m$K$O(BSnow Leopard $B%5%]!<%H$7$J$/$F$bE$i$l$J$$M=46$,$9$k$7(B

$B$G$O(B trunk $B$K$OF~$l$k$3$H$K$7$^$9$+!#(B

$B$"$$$6$o$G$9(B

Lion$B$G$OLdBj$J$/DL$k$h$&$G$9!#$b$&$$$l$A$c$C$F!"C/$+$,(B
[email protected]$C$F$+$i9M$($k$G$$$$$s$8$c$J$$$G$7$g$&$+!#(B
2.0$B$G$k$3$m$K$O(BSnow Leopard $B%5%]!<%H$7$J$/$F$bE$i$l$J$$M=46$,$9$k$7(B

SnowLeopard$B$G$bLdBj$J$/F0$/$3$H$r3NG’$7$^$7$?!#(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs