diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-08 03:15:28 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-08 03:15:28 +0000 |
commit | 703fb3d9becd0626c57f343ce16635c0434f19c6 (patch) | |
tree | 87cde4963e024d99d58a9d38c847b38db52214ce /ext/gdbm | |
parent | 0042ccef2cea6fafecf2edbfee90dd160cee7ba7 (diff) | |
download | ruby-703fb3d9becd0626c57f343ce16635c0434f19c6.tar.gz |
* ext/gdbm/gdbm.c (fgdbm_index): make #index warn like Hash.
[ruby-dev:37039]
* ext/sdbm/init.c (Init_sdbm): typo fixed. [ruby-dev:37039]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/gdbm')
-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); |