summaryrefslogtreecommitdiff
path: root/ext/gdbm/gdbm.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/gdbm/gdbm.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/gdbm/gdbm.c')
-rw-r--r--ext/gdbm/gdbm.c60
1 files changed, 13 insertions, 47 deletions
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index 799445a..49c8614 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -316,56 +316,24 @@ fgdbm_index(obj, valstr)
}
static VALUE
-fgdbm_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, rb_gdbm_fetch3(obj, argv[i]));
- }
-
- return new;
-}
-
-static VALUE
-fgdbm_select(argc, argv, obj)
- int argc;
- VALUE *argv;
+fgdbm_select(obj)
VALUE obj;
{
- VALUE new = rb_ary_new2(argc);
+ VALUE new = rb_ary_new();
int i;
+ GDBM_FILE dbm;
+ struct dbmdata *dbmp;
+ VALUE keystr;
- if (rb_block_given_p()) {
- GDBM_FILE dbm;
- struct dbmdata *dbmp;
- VALUE keystr;
-
- if (argc > 0) {
- rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc);
- }
- GetDBM(obj, dbmp);
- dbm = dbmp->di_dbm;
-
- for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
- keystr = rb_gdbm_nextkey(dbm, keystr)) {
- VALUE assoc = rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr));
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
- if (RTEST(rb_yield(assoc)))
- rb_ary_push(new, assoc);
- }
- }
- else {
- rb_warn("GDBM#select(index..) is deprecated; use GDBM#values_at");
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+ VALUE assoc = rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr));
- for (i=0; i<argc; i++) {
- rb_ary_push(new, rb_gdbm_fetch3(obj, argv[i]));
- }
+ if (RTEST(rb_yield(assoc)))
+ rb_ary_push(new, assoc);
}
return new;
@@ -970,9 +938,7 @@ Init_gdbm()
rb_define_method(rb_cGDBM, "[]=", fgdbm_store, 2);
rb_define_method(rb_cGDBM, "store", fgdbm_store, 2);
rb_define_method(rb_cGDBM, "index", fgdbm_index, 1);
- rb_define_method(rb_cGDBM, "indexes", fgdbm_indexes, -1);
- rb_define_method(rb_cGDBM, "indices", fgdbm_indexes, -1);
- rb_define_method(rb_cGDBM, "select", fgdbm_select, -1);
+ rb_define_method(rb_cGDBM, "select", fgdbm_select, 0);
rb_define_method(rb_cGDBM, "values_at", fgdbm_values_at, -1);
rb_define_method(rb_cGDBM, "length", fgdbm_length, 0);
rb_define_method(rb_cGDBM, "size", fgdbm_length, 0);