summaryrefslogtreecommitdiff
path: root/ext/sdbm/init.c
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/sdbm/init.c
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/sdbm/init.c')
-rw-r--r--ext/sdbm/init.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index ecedd63..b697ca7 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -176,7 +176,7 @@ fsdbm_fetch_m(int argc, VALUE *argv, VALUE obj)
}
static VALUE
-fsdbm_index(VALUE obj, VALUE valstr)
+fsdbm_key(VALUE obj, VALUE valstr)
{
datum key, val;
struct dbmdata *dbmp;
@@ -197,6 +197,13 @@ fsdbm_index(VALUE obj, VALUE valstr)
}
static VALUE
+fsdbm_index(VALUE hash, VALUE value)
+{
+ rb_warn("SDBM#index is deprecated; use SDBM#key");
+ return fsdbm_key(hash, value);
+}
+
+static VALUE
fsdbm_select(VALUE obj)
{
VALUE new = rb_ary_new();
@@ -671,6 +678,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, "index", fsdbm_key, 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);