diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-05-06 06:51:31 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-05-06 06:51:31 +0000 |
commit | 7752fb4205ecf5de2021a7924c213516c8a8d858 (patch) | |
tree | 112f7e4154e500bf48240f8b4cfaab09e351fd6e /ext/gdbm | |
parent | 6154ce97a7915ac70326c007ee04a22fe5742e04 (diff) |
* object.c (rb_obj_methods): list singleton methods if recur
argument is false; list all methods otherwise.
* numeric.c (num_step): double epsilon to make "1.1.step(1.5,0.1)"
to work.
* ext/gdbm/gdbm.c (fgdbm_values_at): new method to replace
select(index..).
* ext/sdbm/init.c (fsdbm_values_at): ditto.
* ext/dbm/dbm.c (fdbm_values_at): ditto.
* ext/dbm/dbm.c (DBM::VERSION): defined.
* ext/gdbm/testgdbm.rb: replace select with values_at.
* ext/sdbm/testsdbm.rb: ditto.
* ext/dbm/testdbm.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/gdbm')
-rw-r--r-- | ext/gdbm/gdbm.c | 19 | ||||
-rw-r--r-- | ext/gdbm/testgdbm.rb | 4 |
2 files changed, 21 insertions, 2 deletions
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c index edbd976231..84996896ab 100644 --- a/ext/gdbm/gdbm.c +++ b/ext/gdbm/gdbm.c @@ -352,6 +352,8 @@ fgdbm_select(argc, argv, obj) } } else { + rb_warn("GDBM#select(index..) is deprecated; use GDBM#values_at"); + for (i=0; i<argc; i++) { rb_ary_push(new, rb_gdbm_fetch3(obj, argv[i])); } @@ -361,6 +363,22 @@ fgdbm_select(argc, argv, obj) } static VALUE +fgdbm_values_at(argc, argv, obj) + int argc; + VALUE *argv; + VALUE obj; +{ + VALUE new = rb_ary_new2(argc); + int i; + + for (i=0; i<argc; i++) { + rb_ary_push(new, rb_gdbm_fetch3(obj, argv[i])); + } + + return new; +} + +static VALUE rb_gdbm_delete(obj, keystr) VALUE obj, keystr; { @@ -938,6 +956,7 @@ Init_gdbm() rb_define_method(rb_cGDBM, "indexes", fgdbm_indexes, -1); rb_define_method(rb_cGDBM, "indices", fgdbm_indexes, -1); rb_define_method(rb_cGDBM, "select", fgdbm_select, -1); + rb_define_method(rb_cGDBM, "values_at", fgdbm_values_at, -1); rb_define_method(rb_cGDBM, "length", fgdbm_length, 0); rb_define_method(rb_cGDBM, "size", fgdbm_length, 0); rb_define_method(rb_cGDBM, "empty?", fgdbm_empty_p, 0); diff --git a/ext/gdbm/testgdbm.rb b/ext/gdbm/testgdbm.rb index 524d3f8ca3..529b0010a2 100644 --- a/ext/gdbm/testgdbm.rb +++ b/ext/gdbm/testgdbm.rb @@ -279,11 +279,11 @@ class TestGDBM < RUNIT::TestCase assert_equals(values.reverse, @gdbm.indexes(*keys.reverse)) end - def test_select + def test_values_at keys = %w(foo bar baz) values = %w(FOO BAR BAZ) @gdbm[keys[0]], @gdbm[keys[1]], @gdbm[keys[2]] = values - assert_equals(values.reverse, @gdbm.select(*keys.reverse)) + assert_equals(values.reverse, @gdbm.values_at(*keys.reverse)) end def test_select_with_block |