summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/gdbm/gdbm.c13
-rw-r--r--ext/sdbm/init.c2
2 files changed, 12 insertions, 3 deletions
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index e6a6e0d..1e83608 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);
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index b697ca7..2e4f75c 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -678,7 +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, "key", 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);