diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/dbm/dbm.c | 10 | ||||
-rw-r--r-- | ext/sdbm/init.c | 10 |
2 files changed, 18 insertions, 2 deletions
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c index 47975cffc2..7a78f8dad0 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); diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c index ecedd6318a..b697ca7380 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); |