summaryrefslogtreecommitdiff
path: root/ext/dbm
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-07 22:07:05 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-07 22:07:05 +0000
commitc82769f2277a8b06ea6a104ab4e7e7c8043d658a (patch)
tree8507f1c371bc65d90da52feb0bb437e0719e0356 /ext/dbm
parent80d16e7403e64c5ba19b83046b3530aeaf4ed62b (diff)
* ext/dbm/dbm.c (fdbm_index): make #index warn like Hash.
* ext/dbm/dbm.c (fdbm_key): new method. * ext/sdbm/init.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dbm')
-rw-r--r--ext/dbm/dbm.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index 47975cf..7a78f8d 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -198,7 +198,7 @@ fdbm_fetch_m(int argc, VALUE *argv, VALUE obj)
}
static VALUE
-fdbm_index(VALUE obj, VALUE valstr)
+fdbm_key(VALUE obj, VALUE valstr)
{
datum key, val;
struct dbmdata *dbmp;
@@ -220,6 +220,13 @@ fdbm_index(VALUE obj, VALUE valstr)
}
static VALUE
+fdbm_index(VALUE hash, VALUE value)
+{
+ rb_warn("DBM#index is deprecated; use DBM#key");
+ return fdbm_key(hash, value);
+}
+
+static VALUE
fdbm_select(VALUE obj)
{
VALUE new = rb_ary_new();
@@ -692,6 +699,7 @@ Init_dbm(void)
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, "key", fdbm_key, 1);
rb_define_method(rb_cDBM, "select", fdbm_select, 0);
rb_define_method(rb_cDBM, "values_at", fdbm_values_at, -1);
rb_define_method(rb_cDBM, "length", fdbm_length, 0);