summaryrefslogtreecommitdiff
path: root/ext/dbm
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/dbm
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/dbm')
-rw-r--r--ext/dbm/dbm.c64
1 files changed, 16 insertions, 48 deletions
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index c76d667..99144aa 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -220,57 +220,25 @@ fdbm_index(obj, valstr)
}
static VALUE
-fdbm_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, fdbm_fetch(obj, argv[i], Qnil));
- }
-
- return new;
-}
-
-static VALUE
-fdbm_select(argc, argv, obj)
- int argc;
- VALUE *argv;
+fdbm_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 arguments(%d for 0)", argc);
- }
- GetDBM(obj, dbmp);
- dbm = dbmp->di_dbm;
-
- for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
- VALUE assoc;
- val = dbm_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("DBM#select(index..) is deprecated; use DBM#values_at");
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
- for (i=0; i<argc; i++) {
- rb_ary_push(new, fdbm_fetch(obj, argv[i], Qnil));
- }
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ VALUE assoc;
+ val = dbm_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;
@@ -766,8 +734,6 @@ Init_dbm()
rb_define_method(rb_cDBM, "[]=", fdbm_store, 2);
rb_define_method(rb_cDBM, "store", fdbm_store, 2);
rb_define_method(rb_cDBM, "index", fdbm_index, 1);
- rb_define_method(rb_cDBM, "indexes", fdbm_indexes, -1);
- rb_define_method(rb_cDBM, "indices", fdbm_indexes, -1);
rb_define_method(rb_cDBM, "select", fdbm_select, -1);
rb_define_method(rb_cDBM, "values_at", fdbm_values_at, -1);
rb_define_method(rb_cDBM, "length", fdbm_length, 0);
@@ -807,5 +773,7 @@ Init_dbm()
#ifdef DB_VERSION_STRING
rb_define_const(rb_cDBM, "VERSION", rb_str_new2(DB_VERSION_STRING));
+#else
+ rb_define_const(rb_cDBM, "VERSION", rb_str_new2("unknown"));
#endif
}