summaryrefslogtreecommitdiff
path: root/ext/sdbm/init.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-11 13:33:47 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-11 13:33:47 +0000
commit21606c6ec56bf11be012f391e43974132ae5646f (patch)
tree2258a25cf98166401ff369394d9bd664b18dc48f /ext/sdbm/init.c
parent6ea8b5094649cb28b5cf1ea7e1c9bed32cf5c31f (diff)
* array.c: remove #indexes, #indices.
* hash.c: ditto. * ext/dbm/dbm.c: remove #indexes, #indices, "values_at" warning from #select. * ext/gdbm/gdbm.c: ditto. * ext/sdbm/init.c: ditto. * ext/dbm/dbm.c (Init_dbm): set VERSION constant as "unknown" when DB_VERSION_STRING is not available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/sdbm/init.c')
-rw-r--r--ext/sdbm/init.c64
1 files changed, 15 insertions, 49 deletions
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index 0f9ae1d..ecd4fd9 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -196,57 +196,25 @@ fsdbm_index(obj, valstr)
}
static VALUE
-fsdbm_indexes(argc, argv, obj)
- int argc;
- VALUE *argv;
- VALUE obj;
-{
- VALUE new;
- int i;
-
- new = rb_ary_new2(argc);
- for (i=0; i<argc; i++) {
- rb_ary_push(new, fsdbm_fetch(obj, argv[i], Qnil));
- }
-
- return new;
-}
-
-static VALUE
-fsdbm_select(argc, argv, obj)
- int argc;
- VALUE *argv;
+fsdbm_select(obj)
VALUE obj;
{
- VALUE new = rb_ary_new2(argc);
+ VALUE new = rb_ary_new();
int i;
+ datum key, val;
+ DBM *dbm;
+ struct dbmdata *dbmp;
- if (rb_block_given_p()) {
- datum key, val;
- DBM *dbm;
- struct dbmdata *dbmp;
-
- if (argc > 0) {
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
- }
- GetDBM(obj, dbmp);
- dbm = dbmp->di_dbm;
-
- for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
- VALUE assoc;
- val = sdbm_fetch(dbm, key);
- assoc = rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
- rb_tainted_str_new(val.dptr, val.dsize));
- if (RTEST(rb_yield(assoc)))
- rb_ary_push(new, assoc);
- }
- }
- else {
- rb_warn("SDBM#select(index..) is deprecated; use SDBM#values_at");
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
- for (i=0; i<argc; i++) {
- rb_ary_push(new, fsdbm_fetch(obj, argv[i], Qnil));
- }
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ VALUE assoc;
+ val = sdbm_fetch(dbm, key);
+ assoc = rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
+ rb_tainted_str_new(val.dptr, val.dsize));
+ if (RTEST(rb_yield(assoc)))
+ rb_ary_push(new, assoc);
}
return new;
@@ -749,9 +717,7 @@ Init_sdbm()
rb_define_method(rb_cDBM, "[]=", fsdbm_store, 2);
rb_define_method(rb_cDBM, "store", fsdbm_store, 2);
rb_define_method(rb_cDBM, "index", fsdbm_index, 1);
- rb_define_method(rb_cDBM, "indexes", fsdbm_indexes, -1);
- rb_define_method(rb_cDBM, "indices", fsdbm_indexes, -1);
- rb_define_method(rb_cDBM, "select", fsdbm_select, -1);
+ rb_define_method(rb_cDBM, "select", fsdbm_select, 0);
rb_define_method(rb_cDBM, "values_at", fsdbm_values_at, -1);
rb_define_method(rb_cDBM, "length", fsdbm_length, 0);
rb_define_method(rb_cDBM, "size", fsdbm_length, 0);