Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Jul 2023 14:34:44 GMT
From:      Dirk Meyer <dinoex@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 5ebb18384791 - main - databases/ruby-bdb: fix build with clang16, fix build with ruby3.2
Message-ID:  <202307131434.36DEYi89028074@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by dinoex:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5ebb18384791d5285f07174a9f665eacf1650a43

commit 5ebb18384791d5285f07174a9f665eacf1650a43
Author:     Dirk Meyer <dinoex@FreeBSD.org>
AuthorDate: 2023-07-13 14:34:26 +0000
Commit:     Dirk Meyer <dinoex@FreeBSD.org>
CommitDate: 2023-07-13 14:34:26 +0000

    databases/ruby-bdb: fix build with clang16, fix build with ruby3.2
---
 databases/ruby-bdb/Makefile                      |    5 +-
 databases/ruby-bdb/files/patch-bdbxml1-bdbxml.cc |    9 +
 databases/ruby-bdb/files/patch-bdbxml2-bdbxml.h  |    4 +-
 databases/ruby-bdb/files/patch-src-bdb.c         |   15 +-
 databases/ruby-bdb/files/patch-src-common.c      | 1091 +++++++++++++++++++++-
 databases/ruby-bdb/files/patch-src-delegator.c   |   11 +
 databases/ruby-bdb/files/patch-src-env.c         |  402 +++++++-
 databases/ruby-bdb/files/patch-src-lock.c        |   11 +
 databases/ruby-bdb/files/patch-src-log.c         |   11 +
 databases/ruby-bdb/files/patch-src-recnum.c      |    9 +
 databases/ruby-bdb/files/patch-src-sequence.c    |   20 +
 databases/ruby-bdb/files/patch-src-transaction.c |   27 +
 12 files changed, 1582 insertions(+), 33 deletions(-)

diff --git a/databases/ruby-bdb/Makefile b/databases/ruby-bdb/Makefile
index c08b74f499e7..7396ee4a97bc 100644
--- a/databases/ruby-bdb/Makefile
+++ b/databases/ruby-bdb/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	bdb
 PORTVERSION=	0.6.6
-PORTREVISION=	8
+PORTREVISION=	9
 CATEGORIES=	databases ruby
 MASTER_SITES=	ftp://ftp.idaemons.org/pub/distfiles/ruby/ \
 		http://idaemons.org/distfiles/ruby/ \
@@ -14,9 +14,6 @@ WWW=		https://github.com/knu/ruby-bdb
 
 LICENSE=	RUBY
 
-BROKEN_RUBY32=	yes
-BROKEN_RUBY33=	yes
-
 BUILD_DEPENDS=	rubygem-rdoc>=0.a:devel/rubygem-rdoc
 
 USES=		bdb ruby:extconf shebangfix tar:bzip2
diff --git a/databases/ruby-bdb/files/patch-bdbxml1-bdbxml.cc b/databases/ruby-bdb/files/patch-bdbxml1-bdbxml.cc
index afd3561f8df8..b7a9b2093410 100644
--- a/databases/ruby-bdb/files/patch-bdbxml1-bdbxml.cc
+++ b/databases/ruby-bdb/files/patch-bdbxml1-bdbxml.cc
@@ -109,3 +109,12 @@
  	}
  
  	xb_eFatal = rb_const_get(xb_mDb, rb_intern("Fatal"));
+@@ -2477,7 +2491,7 @@ extern "C" {
+ 	rb_define_method(xb_cUpd, "<<", RMF(xb_upd_add), 1);
+ 	rb_define_method(xb_cUpd, "delete", RMF(xb_upd_delete), -1);
+ 	rb_define_method(xb_cUpd, "update", RMF(xb_upd_update), -1);
+-	xb_cTmp = rb_define_class_under(xb_mXML, "Tmp", rb_cData);
++	xb_cTmp = rb_define_class_under(xb_mXML, "Tmp", rb_cObject);
+ 	rb_undef_method(CLASS_OF(xb_cTmp), "allocate");
+ 	rb_undef_method(CLASS_OF(xb_cTmp), "new");
+ 	rb_define_method(xb_cTmp, "[]", RMF(xb_cxt_name_get), 1);
diff --git a/databases/ruby-bdb/files/patch-bdbxml2-bdbxml.h b/databases/ruby-bdb/files/patch-bdbxml2-bdbxml.h
index ba92db94b87c..3b9fced8a529 100644
--- a/databases/ruby-bdb/files/patch-bdbxml2-bdbxml.h
+++ b/databases/ruby-bdb/files/patch-bdbxml2-bdbxml.h
@@ -1,11 +1,11 @@
 --- bdbxml2/bdbxml.h.orig	2011-04-06 19:35:39 UTC
 +++ bdbxml2/bdbxml.h
-@@ -377,7 +377,7 @@
+@@ -377,7 +377,7 @@ get_mod(VALUE obj)
  static inline void
  rset_obj(VALUE obj)
  {
 -    RBASIC(obj)->klass = rb_cData;
-+    RBASIC_SET_CLASS_RAW(obj, rb_cData);
++    RBASIC_SET_CLASS_RAW(obj, rb_cObject);
      RDATA(obj)->dfree = (RDF)free;
      RDATA(obj)->dmark = 0;
  }
diff --git a/databases/ruby-bdb/files/patch-src-bdb.c b/databases/ruby-bdb/files/patch-src-bdb.c
index 3ad6c0cb8163..87bc6d797eec 100644
--- a/databases/ruby-bdb/files/patch-src-bdb.c
+++ b/databases/ruby-bdb/files/patch-src-bdb.c
@@ -1,14 +1,16 @@
 --- src/bdb.c.orig	2011-04-06 19:35:39 UTC
 +++ src/bdb.c
-@@ -166,11 +166,10 @@
+@@ -165,12 +165,11 @@ Init_bdb()
+     if (rb_const_defined_at(rb_cObject, rb_intern("BDB"))) {
  	rb_raise(rb_eNameError, "module already defined");
      }
-     version = rb_tainted_str_new2(db_version(&major, &minor, &patch));
+-    version = rb_tainted_str_new2(db_version(&major, &minor, &patch));
 -    if (major != DB_VERSION_MAJOR || minor != DB_VERSION_MINOR
 -	|| patch != DB_VERSION_PATCH) {
 -        rb_raise(rb_eNotImpError, "\nBDB needs compatible versions of libdb & db.h\n\tyou have db.h version %d.%d.%d and libdb version %d.%d.%d\n",
 -		 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
 -		 major, minor, patch);
++    version = rb_str_new_cstr(db_version(&major, &minor, &patch));
 +    if (major != DB_VERSION_MAJOR || minor != DB_VERSION_MINOR) {
 +        rb_raise(rb_eNotImpError, "\nBDB needs compatible versions of libdb & db.h\n\tyou have db.h version %d.%d and libdb version %d.%d\n",
 +		 DB_VERSION_MAJOR, DB_VERSION_MINOR,
@@ -16,3 +18,12 @@
      }
      bdb_mMarshal = rb_const_get(rb_cObject, rb_intern("Marshal"));
      bdb_id_current_db = rb_intern("__bdb_current_db__");
+@@ -958,7 +957,7 @@ Init_bdb()
+     bdb_init_delegator();
+     bdb_init_sequence();
+ 
+-    bdb_errstr = rb_tainted_str_new(0, 0);
++    bdb_errstr = rb_str_new(0, 0);
+     rb_global_variable(&bdb_errstr);
+     
+ }
diff --git a/databases/ruby-bdb/files/patch-src-common.c b/databases/ruby-bdb/files/patch-src-common.c
index ba1783425a39..19682dfb76a5 100644
--- a/databases/ruby-bdb/files/patch-src-common.c
+++ b/databases/ruby-bdb/files/patch-src-common.c
@@ -1,5 +1,32 @@
 --- src/common.c.orig	2011-04-06 19:35:39 UTC
 +++ src/common.c
+@@ -273,7 +273,7 @@ bdb_test_load(VALUE obj, DBT *a, int type_kv)
+                 res = Qnil;
+             }
+             else {
+-                res = rb_tainted_str_new(a->data, a->size);
++                res = rb_str_new(a->data, a->size);
+                 if (dbst->filter[2 + posi]) {
+                     if (FIXNUM_P(dbst->filter[2 + posi])) {
+                         res = rb_funcall(obj, NUM2INT(dbst->filter[2 + posi]),
+@@ -494,7 +494,7 @@ bdb_h_hash(DB *dbbd, const void *bytes, u_int32_t leng
+ #endif
+ 
+     GetIdDbSec(obj, dbst, dbbd);
+-    st = rb_tainted_str_new((char *)bytes, length);
++    st = rb_str_new((char *)bytes, length);
+     if (dbst->h_hash == 0)
+ 	res = rb_funcall(obj, id_h_hash, 1, st);
+     else
+@@ -603,7 +603,7 @@ compar_func(VALUE value)
+ }
+ 
+ static VALUE
+-bdb_i_options(VALUE obj, VALUE dbstobj)
++bdb_i_options(VALUE obj, VALUE dbstobj, int _argc, const VALUE *_argv, VALUE _blockarg)
+ {
+     VALUE key, value;
+     char *options, *str;
 @@ -1080,9 +1080,11 @@ bdb_close(int argc, VALUE *argv, VALUE obj)
      bdb_DB *dbst;
      int flags = 0;
@@ -12,7 +39,27 @@
      Data_Get_Struct(obj, bdb_DB, dbst);
      if (dbst->dbp != NULL) {
  	if (rb_scan_args(argc, argv, "01", &opt)) {
-@@ -1229,7 +1231,7 @@ bdb_s_new(int argc, VALUE *argv, VALUE obj)
+@@ -1140,8 +1142,7 @@ bdb_hard_count(dbp)
+ #endif
+ 
+ static long
+-bdb_is_recnum(dbp)
+-    DB *dbp;
++bdb_is_recnum(DB *dbp)
+ {
+     DB_BTREE_STAT *bdb_stat;
+     long count;
+@@ -1172,8 +1173,7 @@ bdb_is_recnum(dbp)
+ }
+ 
+ static VALUE
+-bdb_recno_length(obj)
+-    VALUE obj;
++bdb_recno_length(VALUE obj)
+ {
+     bdb_DB *dbst;
+     DB_BTREE_STAT *bdb_stat;
+@@ -1229,7 +1229,7 @@ bdb_s_new(int argc, VALUE *argv, VALUE obj)
      if (argc && TYPE(argv[argc - 1]) == T_HASH) {
  	VALUE v, f = argv[argc - 1];
  
@@ -21,7 +68,7 @@
  	    if (!rb_obj_is_kind_of(v, bdb_cTxn)) {
  		rb_raise(bdb_eFatal, "argument of txn must be a transaction");
  	    }
-@@ -1241,7 +1243,7 @@ bdb_s_new(int argc, VALUE *argv, VALUE obj)
+@@ -1241,7 +1241,7 @@ bdb_s_new(int argc, VALUE *argv, VALUE obj)
  	    dbst->options |= envst->options & BDB_NO_THREAD;
  	    dbst->marshal = txnst->marshal;
  	}
@@ -30,7 +77,7 @@
  	    if (!rb_obj_is_kind_of(v, bdb_cEnv)) {
  		rb_raise(bdb_eFatal, "argument of env must be an environnement");
  	    }
-@@ -1254,11 +1256,11 @@ bdb_s_new(int argc, VALUE *argv, VALUE obj)
+@@ -1254,11 +1254,11 @@ bdb_s_new(int argc, VALUE *argv, VALUE obj)
  #if HAVE_CONST_DB_ENCRYPT 
  	if (envst && (envst->options & BDB_ENV_ENCRYPT)) {
  	    VALUE tmp = rb_str_new2("set_flags");
@@ -44,7 +91,16 @@
  		rb_hash_aset(f, tmp, INT2NUM(NUM2INT(v) | DB_ENCRYPT));
  	    }
  	    else {
-@@ -1431,15 +1433,19 @@ bdb_init(int argc, VALUE *argv, VALUE obj)
+@@ -1338,7 +1338,7 @@ bdb_init(int argc, VALUE *argv, VALUE obj)
+ #endif
+     if (argc && TYPE(argv[argc - 1]) == T_HASH) {
+ 	hash_arg = argv[argc - 1];
+-	rb_iterate(rb_each, argv[argc - 1], bdb_i_options, obj);
++	rb_block_call(argv[argc - 1], rb_intern("each"), 0, NULL, bdb_i_options, obj);
+         argc--;
+     }
+     mode = flags = 0;
+@@ -1431,15 +1431,19 @@ bdb_init(int argc, VALUE *argv, VALUE obj)
  	dbst->options |= BDB_FEEDBACK;
      }
  #endif
@@ -64,7 +120,22 @@
  #if HAVE_CONST_DB_DUPSORT
      if (dbst->options & BDB_DUP_COMPARE) {
  #if HAVE_TYPE_DB_INFO
-@@ -1570,10 +1576,10 @@ bdb_init(int argc, VALUE *argv, VALUE obj)
+@@ -1540,12 +1544,12 @@ bdb_init(int argc, VALUE *argv, VALUE obj)
+     }
+     dbst->filename = dbst->database = Qnil;
+     if (name) {
+-	dbst->filename = rb_tainted_str_new2(name);
++	dbst->filename = rb_str_new_cstr(name);
+ 	OBJ_FREEZE(dbst->filename);
+     }
+ #if HAVE_ST_DB_OPEN
+     if (subname) {
+-	dbst->database = rb_tainted_str_new2(subname);
++	dbst->database = rb_str_new_cstr(subname);
+ 	OBJ_FREEZE(dbst->database);
+     }
+ #endif
+@@ -1570,10 +1574,10 @@ bdb_init(int argc, VALUE *argv, VALUE obj)
  #endif
  	switch(dbst->type) {
  	case DB_BTREE:
@@ -77,7 +148,7 @@
  	    break;
  	case DB_RECNO:
  	{
-@@ -1581,17 +1587,17 @@ bdb_init(int argc, VALUE *argv, VALUE obj)
+@@ -1581,17 +1585,17 @@ bdb_init(int argc, VALUE *argv, VALUE obj)
  
  	    rb_warning("It's hard to distinguish Recnum with Recno for all versions of Berkeley DB");
  	    if ((count = bdb_is_recnum(dbst->dbp)) != -1) {
@@ -98,7 +169,17 @@
  	    break;
  #endif
  	default:
-@@ -1635,29 +1641,29 @@ bdb_s_alloc(obj)
+@@ -1625,8 +1629,7 @@ bdb_init(int argc, VALUE *argv, VALUE obj)
+ }
+ 
+ static VALUE
+-bdb_s_alloc(obj)
+-    VALUE obj;
++bdb_s_alloc(VALUE obj)
+ {
+     VALUE res, cl;
+     bdb_DB *dbst;
+@@ -1635,29 +1638,29 @@ bdb_s_alloc(obj)
      dbst->options = BDB_NOT_OPEN;
      cl = obj;
      while (cl) {
@@ -134,9 +215,81 @@
  	    dbst->type = DB_UNKNOWN;
  	    break;
  	}
-@@ -1802,7 +1808,9 @@ bdb_append_internal(argc, argv, obj, flag, retval)
+@@ -1671,8 +1674,7 @@ bdb_s_alloc(obj)
+ }
+ 
+ static VALUE
+-bdb_i_s_create(obj, db)
+-    VALUE obj, db;
++bdb_i_s_create(VALUE obj, VALUE db, int _argc, const VALUE *_argv, VALUE _blockarg)
+ {
+     VALUE tmp[2];
+     tmp[0] = rb_ary_entry(obj, 0);
+@@ -1689,7 +1691,7 @@ bdb_s_create(int argc, VALUE *argv, VALUE obj)
+ 
+     res = rb_funcall2(obj, rb_intern("new"), 0, 0);
+     if (argc == 1 && TYPE(argv[0]) == T_HASH) {
+-	rb_iterate(rb_each, argv[0], bdb_i_s_create, res);
++	rb_block_call(argv[0], rb_intern("each"), 0, NULL, bdb_i_s_create, res);
+ 	return res;
+     }
+     if (argc % 2 != 0) {
+@@ -1718,8 +1720,7 @@ struct re {
+ };
+ 
+ static VALUE
+-bdb_queue_i_search_re_len(obj, restobj)
+-    VALUE obj, restobj;
++bdb_queue_i_search_re_len(VALUE obj, VALUE restobj, int _argc, const VALUE *_argv, VALUE _blockarg)
+ {
+     VALUE key, value;
+     char *str;
+@@ -1760,14 +1761,14 @@ bdb_queue_s_new(int argc, VALUE *argv, VALUE obj) 
+     rest->re_len = -1;
+     rest->re_pad = -1;
+     if (argc && TYPE(argv[argc - 1]) == T_HASH) {
+-	rb_iterate(rb_each, argv[argc - 1], bdb_queue_i_search_re_len, restobj);
++	rb_block_call(argv[argc - 1], rb_intern("each"), 0, NULL, bdb_queue_i_search_re_len, restobj);
+ 	if (rest->re_len <= 0) {
+ 	    rest->re_len = DEFAULT_RECORD_LENGTH;
+-	    rb_hash_aset(argv[argc - 1], rb_tainted_str_new2("set_re_len"), INT2NUM(rest->re_len));
++	    rb_hash_aset(argv[argc - 1], rb_str_new_cstr("set_re_len"), INT2NUM(rest->re_len));
+ 	}
+ 	if (rest->re_pad < 0) {
+ 	    rest->re_pad = DEFAULT_RECORD_PAD;
+-	    rb_hash_aset(argv[argc - 1], rb_tainted_str_new2("set_re_pad"), INT2NUM(rest->re_pad));
++	    rb_hash_aset(argv[argc - 1], rb_str_new_cstr("set_re_pad"), INT2NUM(rest->re_pad));
+ 	}
+ 	nargv = argv;
+     }
+@@ -1777,8 +1778,8 @@ bdb_queue_s_new(int argc, VALUE *argv, VALUE obj) 
+ 	nargv[argc] = rb_hash_new();
+ 	rest->re_len = DEFAULT_RECORD_LENGTH;
+ 	rest->re_pad = DEFAULT_RECORD_PAD;
+-	rb_hash_aset(nargv[argc], rb_tainted_str_new2("set_re_len"), INT2NUM(DEFAULT_RECORD_LENGTH));
+-	rb_hash_aset(nargv[argc], rb_tainted_str_new2("set_re_pad"), INT2NUM(DEFAULT_RECORD_PAD));
++	rb_hash_aset(nargv[argc], rb_str_new_cstr("set_re_len"), INT2NUM(DEFAULT_RECORD_LENGTH));
++	rb_hash_aset(nargv[argc], rb_str_new_cstr("set_re_pad"), INT2NUM(DEFAULT_RECORD_PAD));
+ 	argc += 1;
+     }
+     ret = bdb_s_new(argc, nargv, obj);
+@@ -1790,9 +1791,7 @@ bdb_queue_s_new(int argc, VALUE *argv, VALUE obj) 
+ #endif
+ 
+ static VALUE
+-bdb_append_internal(argc, argv, obj, flag, retval)
+-    int argc, flag;
+-    VALUE *argv, obj;
++bdb_append_internal(int argc, VALUE *argv, VALUE obj, int flag, retval)
+ {
+     bdb_DB *dbst;
+     DB_TXN *txnid;
+@@ -1800,9 +1799,11 @@ bdb_append_internal(argc, argv, obj, flag, retval)
+     db_recno_t recno;
+     int i;
      VALUE *a, ary = Qnil;
-     volatile VALUE res = Qnil;
+-    volatile VALUE res = Qnil;
++    volatile VALUE res;
  
 +#if defined(RUBY_SAFE_LEVEL_MAX) && RUBY_SAFE_LEVEL_MAX >= 4
      rb_secure(4);
@@ -144,7 +297,16 @@
      if (argc < 1)
  	return obj;
      INIT_TXN(txnid, obj, dbst);
-@@ -1885,7 +1893,9 @@ bdb_put(int argc, VALUE *argv, VALUE obj)
+@@ -1876,7 +1877,7 @@ bdb_unshift(int argc, VALUE *argv, VALUE obj)
+ VALUE
+ bdb_put(int argc, VALUE *argv, VALUE obj)
+ {
+-    volatile VALUE a0 = Qnil;
++    volatile VALUE a0;
+     volatile VALUE b0 = Qnil;
+     VALUE a, b, c;
+     bdb_DB *dbst;
+@@ -1885,7 +1886,9 @@ bdb_put(int argc, VALUE *argv, VALUE obj)
      int ret, flags;
      db_recno_t recno;
  
@@ -154,7 +316,226 @@
      INIT_TXN(txnid, obj, dbst);
      flags = 0;
      a = b = c = Qnil;
-@@ -2374,7 +2384,9 @@ bdb_consume(obj)
+@@ -1924,8 +1927,7 @@ bdb_put(int argc, VALUE *argv, VALUE obj)
+ }
+ 
+ static VALUE
+-bdb_aset(obj, a, b)
+-    VALUE obj, a, b;
++bdb_aset(VALUE obj, VALUE a, VALUE b)
+ {
+     VALUE tmp[2];
+     tmp[0] = a;
+@@ -1935,9 +1937,7 @@ bdb_aset(obj, a, b)
+ }
+ 
+ VALUE
+-bdb_test_load_key(obj, key)
+-    VALUE obj;
+-    DBT *key;
++bdb_test_load_key(VALUE obj, DBT *key)
+ {
+     bdb_DB *dbst;
+     Data_Get_Struct(obj, bdb_DB, dbst);
+@@ -1947,18 +1947,14 @@ bdb_test_load_key(obj, key)
+ }
+ 
+ VALUE
+-bdb_assoc(obj, key, data)
+-    VALUE obj;
+-    DBT *key, *data;
++bdb_assoc(VALUE obj, DBT *key, DBT *data)
+ {
+     return rb_assoc_new(bdb_test_load_key(obj, key), 
+ 			bdb_test_load(obj, data, FILTER_VALUE));
+ }
+ 
+ VALUE
+-bdb_assoc_dyna(obj, key, data)
+-    VALUE obj;
+-    DBT *key, *data;
++bdb_assoc_dyna(VALUE obj, DBT *key, DBT *data)
+ {
+     VALUE k, v;
+     int to_free = key->flags & DB_DBT_MALLOC;
+@@ -1976,9 +1972,7 @@ bdb_assoc_dyna(obj, key, data)
+ #if HAVE_ST_DB_PGET
+ 
+ static VALUE
+-bdb_assoc2(obj, skey, pkey, data)
+-    VALUE obj;
+-    DBT *skey, *pkey, *data;
++bdb_assoc2(VALUE obj, DBT *skey, DBT *pkey, DBT *data)
+ {
+     return rb_assoc_new(
+ 	rb_assoc_new(bdb_test_load_key(obj, skey), bdb_test_load_key(obj, pkey)),
+@@ -1988,9 +1982,7 @@ bdb_assoc2(obj, skey, pkey, data)
+ #endif
+ 
+ VALUE
+-bdb_assoc3(obj, skey, pkey, data)
+-    VALUE obj;
+-    DBT *skey, *pkey, *data;
++bdb_assoc3(VALUE obj, DBT *skey, DBT *pkey, DBT *data)
+ {
+     return rb_ary_new3(3, bdb_test_load_key(obj, skey), 
+ 		       bdb_test_load_key(obj, pkey),
+@@ -2006,12 +1998,7 @@ static VALUE bdb_has_both_internal _((VALUE, VALUE, VA
+ #endif
+ 
+ static VALUE
+-bdb_get_internal(argc, argv, obj, notfound, dyna)
+-    int argc;
+-    VALUE *argv;
+-    VALUE obj;
+-    VALUE notfound;
+-    int dyna;
++bdb_get_internal(int argc, VALUE *argv, VALUE obj, VALUE notfound, int dyna)
+ {
+     VALUE a = Qnil;
+     VALUE b = Qnil;
+@@ -2019,13 +2006,12 @@ bdb_get_internal(argc, argv, obj, notfound, dyna)
+     bdb_DB *dbst;
+     DB_TXN *txnid;
+     DBT key, data;
+-    int flagss;
+     int ret, flags;
+     db_recno_t recno;
+     void *tmp_data = 0;
+ 
+     INIT_TXN(txnid, obj, dbst);
+-    flagss = flags = 0;
++    flags = 0;
+     MEMZERO(&key, DBT, 1);
+     MEMZERO(&data, DBT, 1);
+     data.flags |= DB_DBT_MALLOC;
+@@ -2043,7 +2029,7 @@ bdb_get_internal(argc, argv, obj, notfound, dyna)
+         }
+ 	break;
+     case 2:
+-	flagss = flags = NUM2INT(b);
++	flags = NUM2INT(b);
+ 	break;
+     }
+     a = bdb_test_recno(obj, &key, &recno, a);
+@@ -2128,13 +2114,12 @@ bdb_pget(int argc, VALUE *argv, VALUE obj)
+     bdb_DB *dbst;
+     DB_TXN *txnid;
+     DBT pkey, data, skey;
+-    int flagss;
+     int ret, flags;
+     db_recno_t srecno;
+     void *tmp_data = 0;
+ 
+     INIT_TXN(txnid, obj, dbst);
+-    flagss = flags = 0;
++    flags = 0;
+     MEMZERO(&skey, DBT, 1);
+     MEMZERO(&pkey, DBT, 1);
+     MEMZERO(&data, DBT, 1);
+@@ -2150,7 +2135,7 @@ bdb_pget(int argc, VALUE *argv, VALUE obj)
+         }
+ 	break;
+     case 2:
+-	flagss = flags = NUM2INT(b);
++	flags = NUM2INT(b);
+ 	break;
+     }
+     a = bdb_test_recno(obj, &skey, &srecno, a);
+@@ -2174,15 +2159,14 @@ bdb_pget(int argc, VALUE *argv, VALUE obj)
+ #if HAVE_TYPE_DB_KEY_RANGE
+ 
+ static VALUE
+-bdb_btree_key_range(obj, a)
+-    VALUE obj, a;
++bdb_btree_key_range(VALUE obj, VALUE a)
+ {
+     bdb_DB *dbst;
+     DB_TXN *txnid;
+     DBT key;
+     db_recno_t recno;
+     DB_KEY_RANGE key_range;
+-    volatile VALUE b = Qnil;
++    volatile VALUE b;
+ 
+     INIT_TXN(txnid, obj, dbst);
+     MEMZERO(&key, DBT, 1);
+@@ -2203,8 +2187,7 @@ struct data_flags {
+ };
+ 
+ static VALUE
+-bdb_compact_i(obj, dataobj)
+-    VALUE obj, dataobj;
++bdb_compact_i(VALUE obj, VALUE dataobj, int _argc, const VALUE *_argv, VALUE _blockarg)
+ {
+     VALUE key, value;
+     char *str;
+@@ -2255,10 +2238,10 @@ bdb_treerec_compact(int argc, VALUE *argv, VALUE obj)
+ 	    struct data_flags *dtf;
+ 	    VALUE dtobj;
+ 		
+-	    dtobj = Data_Make_Struct(rb_cData, struct data_flags, 0, free, dtf);
++	    dtobj = Data_Make_Struct(rb_cObject, struct data_flags, 0, free, dtf);
+ 	    dtf->cdata = &cdata;
+ 	    dtf->flags = 0;
+-	    rb_iterate(rb_each, c, bdb_compact_i, dtobj);
++	    rb_block_call(c, rb_intern("each"), 0, NULL, bdb_compact_i, dtobj);
+ 	    flags = dtf->flags;
+ 	}
+ 	/* ... */
+@@ -2280,16 +2263,16 @@ bdb_treerec_compact(int argc, VALUE *argv, VALUE obj)
+     bdb_test_error(dbst->dbp->compact(dbst->dbp, txnid, pstart, pstop, &cdata,
+ 				      flags, &end));
+     result = rb_hash_new();
+-    rb_hash_aset(result, rb_tainted_str_new2("end"), bdb_test_load_key(obj, &end));
+-    rb_hash_aset(result, rb_tainted_str_new2("compact_deadlock"),
++    rb_hash_aset(result, rb_str_new_cstr("end"), bdb_test_load_key(obj, &end));
++    rb_hash_aset(result, rb_str_new_cstr("compact_deadlock"),
+ 		 INT2NUM(cdata.compact_deadlock));
+-    rb_hash_aset(result, rb_tainted_str_new2("compact_levels"),
++    rb_hash_aset(result, rb_str_new_cstr("compact_levels"),
+ 		 INT2NUM(cdata.compact_levels));
+-    rb_hash_aset(result, rb_tainted_str_new2("compact_pages_free"),
++    rb_hash_aset(result, rb_str_new_cstr("compact_pages_free"),
+ 		 INT2NUM(cdata.compact_pages_free));
+-    rb_hash_aset(result, rb_tainted_str_new2("compact_pages_examine"),
++    rb_hash_aset(result, rb_str_new_cstr("compact_pages_examine"),
+ 		 INT2NUM(cdata.compact_pages_examine));
+-    rb_hash_aset(result, rb_tainted_str_new2("compact_pages_truncated"),
++    rb_hash_aset(result, rb_str_new_cstr("compact_pages_truncated"),
+ 		 INT2NUM(cdata.compact_pages_truncated));
+     return result;
+ }
+@@ -2301,8 +2284,7 @@ bdb_treerec_compact(int argc, VALUE *argv, VALUE obj)
+ #if HAVE_CONST_DB_NEXT_DUP
+ 
+ static VALUE
+-bdb_count(obj, a)
+-    VALUE obj, a;
++bdb_count(VALUE obj, VALUE a)
+ {
+     bdb_DB *dbst;
+     DB_TXN *txnid;
+@@ -2311,7 +2293,7 @@ bdb_count(obj, a)
+     int ret, flags27;
+     db_recno_t recno;
+     db_recno_t count;
+-    volatile VALUE b = Qnil;
++    volatile VALUE b;
+ 
+     INIT_TXN(txnid, obj, dbst);
+     MEMZERO(&key, DBT, 1);
+@@ -2364,8 +2346,7 @@ bdb_count(obj, a)
+ #if HAVE_CONST_DB_CONSUME
+ 
+ static VALUE
+-bdb_consume(obj)
+-    VALUE obj;
++bdb_consume(VALUE obj)
+ {
+     bdb_DB *dbst;
+     DB_TXN *txnid;
+@@ -2374,7 +2355,9 @@ bdb_consume(obj)
      int ret;
      db_recno_t recno;
  
@@ -164,9 +545,63 @@
      INIT_TXN(txnid, obj, dbst);
      MEMZERO(&key, DBT, 1);
      MEMZERO(&data, DBT, 1);
-@@ -2551,7 +2563,9 @@ bdb_del(obj, a)
+@@ -2396,8 +2379,7 @@ bdb_consume(obj)
+ #endif
+ 
+ static VALUE
+-bdb_has_key(obj, key)
+-    VALUE obj, key;
++bdb_has_key(VALUE obj, VALUE key)
+ {
+     return (bdb_get_internal(1, &key, obj, Qundef, 0) == Qundef)?Qfalse:Qtrue;
+ }
+@@ -2405,8 +2387,7 @@ bdb_has_key(obj, key)
+ #if CANT_DB_CURSOR_GET_BOTH
+ 
+ static VALUE
+-bdb_has_both_internal(obj, a, b, flag)
+-    VALUE obj, a, b, flag;
++bdb_has_both_internal(VALUE obj, VALUE a, VALUE b, VALUE flag)
+ {
+     bdb_DB *dbst;
+     DB_TXN *txnid;
+@@ -2491,8 +2472,7 @@ bdb_has_both_internal(obj, a, b, flag)
+ #endif
+ 
+ static VALUE
+-bdb_has_both(obj, a, b)
+-    VALUE obj, a, b;
++bdb_has_both(VALUE obj, VALUE a, VALUE b)
+ {
+ #if ! HAVE_CONST_DB_GET_BOTH
+     return bdb_has_both_internal(obj, a, b, Qfalse);
+@@ -2502,8 +2482,8 @@ bdb_has_both(obj, a, b)
+     DBT key, data;
+     int ret, flags;
+     db_recno_t recno;
+-    volatile VALUE c = Qnil;
+-    volatile VALUE d = Qnil;
++    volatile VALUE c;
++    volatile VALUE d;
+     void *tmp_key, *tmp_data;
+ 
+     INIT_TXN(txnid, obj, dbst);
+@@ -2540,8 +2520,7 @@ bdb_has_both(obj, a, b)
+ }
+ 
+ VALUE
+-bdb_del(obj, a)
+-    VALUE a, obj;
++bdb_del(VALUE obj, VALUE a)
+ {
+     bdb_DB *dbst;
+     DB_TXN *txnid;
+@@ -2549,9 +2528,11 @@ bdb_del(obj, a)
+     DBT key;
+     int ret;
      db_recno_t recno;
-     volatile VALUE b = Qnil;
+-    volatile VALUE b = Qnil;
++    volatile VALUE b;
  
 +#if defined(RUBY_SAFE_LEVEL_MAX) && RUBY_SAFE_LEVEL_MAX >= 4
      rb_secure(4);
@@ -174,7 +609,142 @@
      INIT_TXN(txnid, obj, dbst);
  #if HAVE_CONST_DB_AUTO_COMMIT
      if (txnid == NULL && (dbst->options & BDB_AUTO_COMMIT)) {
-@@ -3004,8 +3018,8 @@ bdb_each_kvc(argc, argv, obj, sens, replace, type)
+@@ -2568,8 +2549,7 @@ bdb_del(obj, a)
+ }
+ 
+ static VALUE
+-bdb_empty(obj)
+-    VALUE obj;
++bdb_empty(VALUE obj)
+ {
+     bdb_DB *dbst;
+     DB_TXN *txnid;
+@@ -2603,8 +2583,7 @@ bdb_empty(obj)
+ }
+ 
+ static VALUE
+-bdb_lgth_intern(obj, delete)
+-    VALUE obj, delete;
++bdb_lgth_intern(VALUE obj, VALUE delete)
+ {
+     bdb_DB *dbst;
+     DB_TXN *txnid;
+@@ -2646,8 +2625,7 @@ bdb_lgth_intern(obj, delete)
+ }
+ 
+ static VALUE
+-bdb_length(obj)
+-    VALUE obj;
++bdb_length(VALUE obj)
+ {
+     return bdb_lgth_intern(obj, Qfalse);
+ }
+@@ -2667,10 +2645,10 @@ typedef struct {
+ } eachst;
+ 
+ static VALUE
+-bdb_each_ensure(st)
+-    eachst *st;
++bdb_each_ensure(VALUE pst)
+ {
+ #if HAVE_CONST_DB_MULTIPLE_KEY
++    eachst *st = (eachst *)pst;
+     if (st->len && st->data) {
+ 	free(st->data);
+     }
+@@ -2680,9 +2658,7 @@ bdb_each_ensure(st)
+ }
+ 
+ static void
+-bdb_treat(st, pkey, key, data)
+-    eachst *st;
+-    DBT *pkey, *key, *data;
++bdb_treat(eachst *st, DBT *pkey, DBT *key, DBT *data)
+ {
+     bdb_DB *dbst;
+     DBC *dbcp;
+@@ -2772,10 +2748,7 @@ bdb_treat(st, pkey, key, data)
+ }
+ 
+ static int
+-bdb_i_last_prefix(dbcp, key, pkey, data, orig, st)
+-    DBC *dbcp;
+-    DBT *key, *pkey, *data, *orig;
+-    eachst *st;
++bdb_i_last_prefix(DBC *dbcp, DBT *key, DBT *pkey, DBT *data, DBT *orig, eachst *st)
+ {
+     int ret, flags = DB_LAST;
+ 
+@@ -2811,15 +2784,14 @@ bdb_i_last_prefix(dbcp, key, pkey, data, orig, st)
+ }
+ 
+ static VALUE
+-bdb_i_each_kv(st)
+-    eachst *st;
++bdb_i_each_kv(VALUE pst)
+ {
++    eachst *st = (eachst *)pst;
+     bdb_DB *dbst;
+     DBC *dbcp;
+     DBT pkey, key, data, orig;
+     int ret, init = Qfalse, prefix = Qfalse;
+     db_recno_t recno;
+-    volatile VALUE res = Qnil;
+     
+     prefix = st->type & BDB_ST_PREFIX;
+     st->type &= ~BDB_ST_PREFIX;
+@@ -2834,7 +2806,7 @@ bdb_i_each_kv(st)
+     MEMZERO(&pkey, DBT, 1);
+     pkey.flags = DB_DBT_MALLOC;
+     if (!NIL_P(st->set)) {
+-	res = bdb_test_recno(st->db, &key, &recno, st->set);
++	bdb_test_recno(st->db, &key, &recno, st->set);
+         if (prefix) {
+             init = Qtrue;
+             orig.size = key.size;
+@@ -2929,9 +2901,9 @@ bdb_i_each_kv(st)
+ #if HAVE_CONST_DB_MULTIPLE_KEY
+ 
+ static VALUE
+-bdb_i_each_kv_bulk(st)
+-    eachst *st;
++bdb_i_each_kv_bulk(VALUE pst)
+ {
++    eachst *st = (eachst *)pst;
+     bdb_DB *dbst;
+     DBC *dbcp;
+     DBT key, data;
+@@ -2940,7 +2912,6 @@ bdb_i_each_kv_bulk(st)
+     int ret, init;
+     db_recno_t recno;
+     void *p;
+-    volatile VALUE res = Qnil;
+     
+     GetDB(st->db, dbst);
+     dbcp = st->dbcp;
+@@ -2958,7 +2929,7 @@ bdb_i_each_kv_bulk(st)
+     init = 1;
+     do {
+ 	if (init && !NIL_P(st->set)) {
+-	    res = bdb_test_recno(st->db, &key, &recno, st->set);
++	    bdb_test_recno(st->db, &key, &recno, st->set);
+ 	    ret = bdb_test_error(dbcp->c_get(dbcp, &key, &data, 
+                                              ((st->type & BDB_ST_DUP)?DB_SET:
+                                               DB_SET_RANGE)|DB_MULTIPLE_KEY));
+@@ -2990,11 +2961,7 @@ bdb_i_each_kv_bulk(st)
+ #endif
+ 
+ VALUE
+-bdb_each_kvc(argc, argv, obj, sens, replace, type)
+-    VALUE obj, *argv;
+-    int argc, sens;
+-    VALUE replace;
+-    int type;
++bdb_each_kvc(int argc, VALUE *argv, VALUE obj, int sens, VALUE replace, int type)
+ {
+     bdb_DB *dbst;
+     DB_TXN *txnid;
+@@ -3004,8 +2971,8 @@ bdb_each_kvc(argc, argv, obj, sens, replace, type)
  
      if (argc && TYPE(argv[argc - 1]) == T_HASH) {
  	VALUE g, f = argv[argc - 1];
@@ -185,7 +755,7 @@
  	    flags = NUM2INT(g);
  	}
  	argc--;
-@@ -3053,9 +3067,11 @@ bdb_each_kvc(argc, argv, obj, sens, replace, type)
+@@ -3053,9 +3020,11 @@ bdb_each_kvc(argc, argv, obj, sens, replace, type)
      }
  #endif
      type &= ~BDB_ST_ONE;
@@ -197,7 +767,56 @@
      INIT_TXN(txnid, obj, dbst);
  #if HAVE_DB_CURSOR_4
      bdb_test_error(dbst->dbp->cursor(dbst->dbp, txnid, &dbcp, flags));
-@@ -3309,7 +3325,9 @@ bdb_clear(int argc, VALUE *argv, VALUE obj)
+@@ -3211,8 +3180,7 @@ bdb_each_riap_prim(int argc, VALUE *argv, VALUE obj) 
+ }
+ 
+ VALUE
+-bdb_to_type(obj, result, flag)
+-    VALUE obj, result, flag;
++bdb_to_type(VALUE obj, VALUE result, VALUE flag)
+ {
+     bdb_DB *dbst;
+     DB_TXN *txnid;
+@@ -3266,15 +3234,13 @@ bdb_to_type(obj, result, flag)
+ }
+ 
+ static VALUE
+-bdb_to_a(obj)
+-    VALUE obj;
++bdb_to_a(VALUE obj)
+ {
+     return bdb_to_type(obj, rb_ary_new(), Qtrue);
+ }
+ 
+ static VALUE
+-bdb_update_i(pair, obj)
+-    VALUE pair, obj;
++bdb_update_i(VALUE pair, VALUE obj, int _argc, const VALUE *_argv, VALUE _blockarg)
+ {
+     Check_Type(pair, T_ARRAY);
+     if (RARRAY_LEN(pair) < 2) {
+@@ -3285,17 +3251,15 @@ bdb_update_i(pair, obj)
+ }
+ 
+ static VALUE
+-each_pair(obj)
+-    VALUE obj;
++each_pair(VALUE obj)
+ {
+     return rb_funcall(obj, rb_intern("each_pair"), 0, 0);
+ }
+ 
+ static VALUE
+-bdb_update(obj, other)
+-    VALUE obj, other;
++bdb_update(VALUE obj, VALUE other)
+ {
+-    rb_iterate(each_pair, other, bdb_update_i, obj);
++    rb_block_call(other, each_pair, 0, NULL, bdb_update_i, obj);
+     return obj;
+ }
+ 
+@@ -3309,7 +3273,9 @@ bdb_clear(int argc, VALUE *argv, VALUE obj)
  #endif
      int flags = 0;
  
@@ -207,7 +826,7 @@
  #if HAVE_ST_DB_TRUNCATE
      INIT_TXN(txnid, obj, dbst);
  #if HAVE_CONST_DB_AUTO_COMMIT
-@@ -3323,8 +3341,8 @@ bdb_clear(int argc, VALUE *argv, VALUE obj)
+@@ -3323,8 +3289,8 @@ bdb_clear(int argc, VALUE *argv, VALUE obj)
      flags = 0;
      if (argc && TYPE(argv[argc - 1]) == T_HASH) {
  	VALUE g, f = argv[argc - 1];
@@ -218,7 +837,7 @@
  	    flags = NUM2INT(g);
  	}
  	argc--;
-@@ -3348,8 +3366,8 @@ bdb_replace(int argc, VALUE *argv, VALUE obj)
+@@ -3348,8 +3314,8 @@ bdb_replace(int argc, VALUE *argv, VALUE obj)
      flags = 0;
      if (TYPE(argv[argc - 1]) == T_HASH) {
  	VALUE f = argv[argc - 1];
@@ -229,7 +848,91 @@
  	    flags = NUM2INT(g);
  	}
  	argc--;
-@@ -3557,8 +3575,10 @@ bdb_sync(obj)
+@@ -3359,28 +3325,24 @@ bdb_replace(int argc, VALUE *argv, VALUE obj)
+     }
+     g = INT2FIX(flags);
+     bdb_clear(1, &g, obj);
+-    rb_iterate(each_pair, argv[0], bdb_update_i, obj);
++    rb_block_call(argv[0], rb_intern("each_pair"), 0, NULL, bdb_update_i, obj);
+     return obj;
+ }
+ 
+ static VALUE
+-bdb_invert(obj)
+-    VALUE obj;
++bdb_invert(VALUE obj)
+ {
+     return bdb_to_type(obj, rb_hash_new(), Qfalse);
+ }
+ 
+ static VALUE
+-bdb_to_hash(obj)
+-    VALUE obj;
++bdb_to_hash(VALUE obj)
+ {
+     return bdb_to_type(obj, rb_hash_new(), Qtrue);
+ }
+  
+ static VALUE
+-bdb_kv(obj, type)
+-    VALUE obj;
+-    int type;
++bdb_kv(VALUE obj, int type)
+ {
+     bdb_DB *dbst;
+     DB_TXN *txnid;
+@@ -3426,23 +3388,19 @@ bdb_kv(obj, type)
+ }
+ 
+ static VALUE
+-bdb_values(obj)
+-    VALUE obj;
++bdb_values(VALUE obj)
+ {
+     return bdb_kv(obj, BDB_ST_VALUE);
+ }
+ 
+ static VALUE
+-bdb_keys(obj)
+-    VALUE obj;
++bdb_keys(VALUE obj)
+ {
+     return bdb_kv(obj, BDB_ST_KEY);
+ }
+ 
+ VALUE
+-bdb_internal_value(obj, a, b, sens)
+-    VALUE obj, a, b;
+-    int sens;
++bdb_internal_value(VALUE obj, VALUE a, VALUE b, int sens)
+ {
+     bdb_DB *dbst;
+     DB_TXN *txnid;
+@@ -3490,8 +3448,7 @@ bdb_internal_value(obj, a, b, sens)
+ }
+ 
+ VALUE
+-bdb_index(obj, a)
+-    VALUE obj, a;
++bdb_index(VALUE obj, VALUE a)
+ {
+     return bdb_internal_value(obj, a, Qtrue, DB_NEXT);
+ }
+@@ -3545,20 +3502,20 @@ bdb_select(int argc, VALUE *argv, VALUE obj)
+ }
+ 
+ VALUE
+-bdb_has_value(obj, a)
+-    VALUE obj, a;
++bdb_has_value(VALUE obj, VALUE a)
+ {
+     return bdb_internal_value(obj, a, Qfalse, DB_NEXT);
+ }
+ 
+ static VALUE
+-bdb_sync(obj)
+-    VALUE obj;
*** 948 LINES SKIPPED ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307131434.36DEYi89028074>