diff options
Diffstat (limited to 'ext/gdbm/gdbm.c')
-rw-r--r-- | ext/gdbm/gdbm.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c index e6a6e0d039..1e83608132 100644 --- a/ext/gdbm/gdbm.c +++ b/ext/gdbm/gdbm.c @@ -396,13 +396,13 @@ fgdbm_fetch_m(int argc, VALUE *argv, VALUE obj) /* * call-seq: - * gdbm.index(value) -> key + * gdbm.key(value) -> key * * Returns the _key_ for a given _value_. If several keys may map to the * same value, the key that is found first will be returned. */ static VALUE -fgdbm_index(VALUE obj, VALUE valstr) +fgdbm_key(VALUE obj, VALUE valstr) { struct dbmdata *dbmp; GDBM_FILE dbm; @@ -424,6 +424,14 @@ fgdbm_index(VALUE obj, VALUE valstr) return Qnil; } +/* :nodoc: */ +static VALUE +fgdbm_index(VALUE obj, VALUE value) +{ + rb_warn("GDBM#index is deprecated; use GDBM#key"); + return fgdbm_key(obj, value); +} + /* * call-seq: * gdbm.select { |value| block } -> array @@ -1180,6 +1188,7 @@ Init_gdbm(void) 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, "key", fgdbm_key, 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); |