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 | b50032c8eda65e3aca62f13fd13129e70e8e1138 (patch) | |
tree | 112f7e4154e500bf48240f8b4cfaab09e351fd6e /ext/sdbm | |
parent | 28fc7d479b5a06a89f338b1fecb087ef4068b370 (diff) | |
download | ruby-b50032c8eda65e3aca62f13fd13129e70e8e1138.tar.gz ruby-b50032c8eda65e3aca62f13fd13129e70e8e1138.tar.xz ruby-b50032c8eda65e3aca62f13fd13129e70e8e1138.zip |
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@3758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/sdbm')
-rw-r--r-- | ext/sdbm/init.c | 19 | ||||
-rw-r--r-- | ext/sdbm/testsdbm.rb | 6 |
2 files changed, 22 insertions, 3 deletions
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c index f20e3cfa5..f47355584 100644 --- a/ext/sdbm/init.c +++ b/ext/sdbm/init.c @@ -242,6 +242,8 @@ fsdbm_select(argc, argv, obj) } } else { + rb_warn("SDBM#select(index..) is deprecated; use SDBM#values_at"); + for (i=0; i<argc; i++) { rb_ary_push(new, fsdbm_fetch(obj, argv[i], Qnil)); } @@ -251,6 +253,22 @@ fsdbm_select(argc, argv, obj) } static VALUE +fsdbm_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, fsdbm_fetch(obj, argv[i], Qnil)); + } + + return new; +} + +static VALUE fsdbm_delete(obj, keystr) VALUE obj, keystr; { @@ -728,6 +746,7 @@ Init_sdbm() rb_define_method(rb_cDBM, "indexes", fsdbm_indexes, -1); rb_define_method(rb_cDBM, "indices", fsdbm_indexes, -1); rb_define_method(rb_cDBM, "select", fsdbm_select, -1); + rb_define_method(rb_cDBM, "values_at", fsdbm_values_at, -1); rb_define_method(rb_cDBM, "length", fsdbm_length, 0); rb_define_method(rb_cDBM, "size", fsdbm_length, 0); rb_define_method(rb_cDBM, "empty?", fsdbm_empty_p, 0); diff --git a/ext/sdbm/testsdbm.rb b/ext/sdbm/testsdbm.rb index 550b47a00..3577d3606 100644 --- a/ext/sdbm/testsdbm.rb +++ b/ext/sdbm/testsdbm.rb @@ -51,7 +51,7 @@ class TestSDBM < RUNIT::TestCase end def test_version - STDERR.print SDBM::VERSION + assert(! SDBM.const_defined?(:VERSION)) end def test_s_new_has_no_block @@ -219,11 +219,11 @@ class TestSDBM < RUNIT::TestCase assert_equals(values.reverse, @sdbm.indexes(*keys.reverse)) end - def test_select + def test_values_at keys = %w(foo bar baz) values = %w(FOO BAR BAZ) @sdbm[keys[0]], @sdbm[keys[1]], @sdbm[keys[2]] = values - assert_equals(values.reverse, @sdbm.select(*keys.reverse)) + assert_equals(values.reverse, @sdbm.values_at(*keys.reverse)) end def test_select_with_block |