зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
6154ce97a7
Коммит
7752fb4205
30
ChangeLog
30
ChangeLog
|
@ -1,3 +1,31 @@
|
||||||
|
Tue May 6 14:39:36 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
Mon May 5 21:19:25 2003 Koji Arai <jca02266@nifty.ne.jp>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
* ext/dbm/testdbm.rb (setup): DBM.open(path, 0400) cause EACCESS
|
||||||
|
on Berkeley DB[234].
|
||||||
|
|
||||||
Mon May 5 22:57:07 2003 Tadayoshi Funaba <tadf@dotrb.org>
|
Mon May 5 22:57:07 2003 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
* sample/cal.rb: use values_at instead of select.
|
* sample/cal.rb: use values_at instead of select.
|
||||||
|
@ -48,8 +76,6 @@ Sat May 3 11:00:12 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
warnings to show migration path. The default will be reversed
|
warnings to show migration path. The default will be reversed
|
||||||
on Jan 2004.
|
on Jan 2004.
|
||||||
|
|
||||||
* numeric.c (num_step): "1.1.step(1.5,0.1)" to work.
|
|
||||||
|
|
||||||
Sat May 3 00:58:53 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Sat May 3 00:58:53 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* object.c (rb_obj_methods): now accepts recurse parameter.
|
* object.c (rb_obj_methods): now accepts recurse parameter.
|
||||||
|
|
13
class.c
13
class.c
|
@ -589,7 +589,6 @@ rb_class_protected_instance_methods(argc, argv, mod)
|
||||||
recur = Qtrue;
|
recur = Qtrue;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (argc == 0) recur = Qtrue;
|
|
||||||
return method_list(mod, RTEST(recur), ins_methods_prot_i);
|
return method_list(mod, RTEST(recur), ins_methods_prot_i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,7 +608,6 @@ rb_class_private_instance_methods(argc, argv, mod)
|
||||||
recur = Qtrue;
|
recur = Qtrue;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (argc == 0) recur = Qtrue;
|
|
||||||
return method_list(mod, RTEST(recur), ins_methods_priv_i);
|
return method_list(mod, RTEST(recur), ins_methods_priv_i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,14 +622,11 @@ rb_class_public_instance_methods(argc, argv, mod)
|
||||||
rb_scan_args(argc, argv, "01", &recur);
|
rb_scan_args(argc, argv, "01", &recur);
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
#if RUBY_RELEASE_CODE < 20040101
|
#if RUBY_RELEASE_CODE < 20040101
|
||||||
rb_warn("instance_methods parameter will default to 'true' in Jan 2004");
|
rb_warn("public_instance_methods parameter will default to 'true' in Jan 2004");
|
||||||
#else
|
#else
|
||||||
recur = Qtrue;
|
recur = Qtrue;
|
||||||
#endif
|
#endif
|
||||||
rb_warn("public_instance_methods parameter will default to 'true' in Jan 2004");
|
|
||||||
/* recur = Qtrue; */
|
|
||||||
}
|
}
|
||||||
if (argc == 0) recur = Qtrue;
|
|
||||||
return method_list(mod, RTEST(recur), ins_methods_pub_i);
|
return method_list(mod, RTEST(recur), ins_methods_pub_i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,10 +636,10 @@ rb_obj_singleton_methods(argc, argv, obj)
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE obj;
|
VALUE obj;
|
||||||
{
|
{
|
||||||
VALUE all, ary, klass;
|
VALUE recur, ary, klass;
|
||||||
st_table *list;
|
st_table *list;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "01", &all);
|
rb_scan_args(argc, argv, "01", &recur);
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
#if RUBY_RELEASE_CODE < 20040101
|
#if RUBY_RELEASE_CODE < 20040101
|
||||||
rb_warn("singleton_methods parameter will default to 'true' in Jan 2004");
|
rb_warn("singleton_methods parameter will default to 'true' in Jan 2004");
|
||||||
|
@ -658,7 +653,7 @@ rb_obj_singleton_methods(argc, argv, obj)
|
||||||
st_foreach(RCLASS(klass)->m_tbl, method_entry, (st_data_t)list);
|
st_foreach(RCLASS(klass)->m_tbl, method_entry, (st_data_t)list);
|
||||||
klass = RCLASS(klass)->super;
|
klass = RCLASS(klass)->super;
|
||||||
}
|
}
|
||||||
if (RTEST(all)) {
|
if (RTEST(recur)) {
|
||||||
while (klass && TYPE(klass) == T_ICLASS) {
|
while (klass && TYPE(klass) == T_ICLASS) {
|
||||||
st_foreach(RCLASS(klass)->m_tbl, method_entry, (st_data_t)list);
|
st_foreach(RCLASS(klass)->m_tbl, method_entry, (st_data_t)list);
|
||||||
klass = RCLASS(klass)->super;
|
klass = RCLASS(klass)->super;
|
||||||
|
|
|
@ -254,6 +254,8 @@ fdbm_select(argc, argv, obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
rb_warn("DBM#select(index..) is deprecated; use DBM#values_at");
|
||||||
|
|
||||||
for (i=0; i<argc; i++) {
|
for (i=0; i<argc; i++) {
|
||||||
rb_ary_push(new, fdbm_fetch(obj, argv[i], Qnil));
|
rb_ary_push(new, fdbm_fetch(obj, argv[i], Qnil));
|
||||||
}
|
}
|
||||||
|
@ -262,6 +264,22 @@ fdbm_select(argc, argv, obj)
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
fdbm_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, fdbm_fetch(obj, argv[i], Qnil));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fdbm_delete(obj, keystr)
|
fdbm_delete(obj, keystr)
|
||||||
VALUE obj, keystr;
|
VALUE obj, keystr;
|
||||||
|
@ -731,6 +749,7 @@ Init_dbm()
|
||||||
rb_define_method(rb_cDBM, "indexes", fdbm_indexes, -1);
|
rb_define_method(rb_cDBM, "indexes", fdbm_indexes, -1);
|
||||||
rb_define_method(rb_cDBM, "indices", fdbm_indexes, -1);
|
rb_define_method(rb_cDBM, "indices", fdbm_indexes, -1);
|
||||||
rb_define_method(rb_cDBM, "select", fdbm_select, -1);
|
rb_define_method(rb_cDBM, "select", fdbm_select, -1);
|
||||||
|
rb_define_method(rb_cDBM, "values_at", fdbm_values_at, -1);
|
||||||
rb_define_method(rb_cDBM, "length", fdbm_length, 0);
|
rb_define_method(rb_cDBM, "length", fdbm_length, 0);
|
||||||
rb_define_method(rb_cDBM, "size", fdbm_length, 0);
|
rb_define_method(rb_cDBM, "size", fdbm_length, 0);
|
||||||
rb_define_method(rb_cDBM, "empty?", fdbm_empty_p, 0);
|
rb_define_method(rb_cDBM, "empty?", fdbm_empty_p, 0);
|
||||||
|
@ -759,4 +778,8 @@ Init_dbm()
|
||||||
|
|
||||||
rb_define_method(rb_cDBM, "to_a", fdbm_to_a, 0);
|
rb_define_method(rb_cDBM, "to_a", fdbm_to_a, 0);
|
||||||
rb_define_method(rb_cDBM, "to_hash", fdbm_to_hash, 0);
|
rb_define_method(rb_cDBM, "to_hash", fdbm_to_hash, 0);
|
||||||
|
|
||||||
|
#ifdef DB_VERSION_STRING
|
||||||
|
rb_define_const(rb_cDBM, "VERSION", rb_str_new2(DB_VERSION_STRING));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,12 @@ class TestDBM < RUNIT::TestCase
|
||||||
assert_instance_of(DBM, @dbm = DBM.new(@path))
|
assert_instance_of(DBM, @dbm = DBM.new(@path))
|
||||||
|
|
||||||
# prepare to make readonly DBM file
|
# prepare to make readonly DBM file
|
||||||
DBM.open("tmptest_dbm_rdonly", 0400) {|dbm|
|
DBM.open("tmptest_dbm_rdonly") {|dbm|
|
||||||
dbm['foo'] = 'FOO'
|
dbm['foo'] = 'FOO'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File.chmod(0400, *Dir.glob("tmptest_dbm_rdonly.*"))
|
||||||
|
|
||||||
assert_instance_of(DBM, @dbm_rdonly = DBM.new("tmptest_dbm_rdonly", nil))
|
assert_instance_of(DBM, @dbm_rdonly = DBM.new("tmptest_dbm_rdonly", nil))
|
||||||
end
|
end
|
||||||
def teardown
|
def teardown
|
||||||
|
@ -83,7 +86,7 @@ class TestDBM < RUNIT::TestCase
|
||||||
}
|
}
|
||||||
begin
|
begin
|
||||||
sleep 1
|
sleep 1
|
||||||
assert_exception(Errno::EWOULDBLOCK) {
|
assert_exception(Errno::EWOULDBLOCK, "NEVER MIND IF YOU USE Berkeley DB3") {
|
||||||
begin
|
begin
|
||||||
assert_instance_of(DBM, dbm2 = DBM.open("tmptest_dbm", 0644))
|
assert_instance_of(DBM, dbm2 = DBM.open("tmptest_dbm", 0644))
|
||||||
rescue Errno::EAGAIN, Errno::EACCES, Errno::EINVAL
|
rescue Errno::EAGAIN, Errno::EACCES, Errno::EINVAL
|
||||||
|
@ -154,7 +157,7 @@ class TestDBM < RUNIT::TestCase
|
||||||
|
|
||||||
def test_s_open_error
|
def test_s_open_error
|
||||||
assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm", 0))
|
assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm", 0))
|
||||||
assert_exception(Errno::EACCES) {
|
assert_exception(Errno::EACCES, "NEVER MIND IF YOU USE Berkeley DB3") {
|
||||||
DBM.open("tmptest_dbm", 0)
|
DBM.open("tmptest_dbm", 0)
|
||||||
}
|
}
|
||||||
dbm.close
|
dbm.close
|
||||||
|
@ -245,11 +248,11 @@ class TestDBM < RUNIT::TestCase
|
||||||
assert_equals(values.reverse, @dbm.indexes(*keys.reverse))
|
assert_equals(values.reverse, @dbm.indexes(*keys.reverse))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_select
|
def test_values_at
|
||||||
keys = %w(foo bar baz)
|
keys = %w(foo bar baz)
|
||||||
values = %w(FOO BAR BAZ)
|
values = %w(FOO BAR BAZ)
|
||||||
@dbm[keys[0]], @dbm[keys[1]], @dbm[keys[2]] = values
|
@dbm[keys[0]], @dbm[keys[1]], @dbm[keys[2]] = values
|
||||||
assert_equals(values.reverse, @dbm.select(*keys.reverse))
|
assert_equals(values.reverse, @dbm.values_at(*keys.reverse))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_select_with_block
|
def test_select_with_block
|
||||||
|
|
|
@ -352,6 +352,8 @@ fgdbm_select(argc, argv, obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
rb_warn("GDBM#select(index..) is deprecated; use GDBM#values_at");
|
||||||
|
|
||||||
for (i=0; i<argc; i++) {
|
for (i=0; i<argc; i++) {
|
||||||
rb_ary_push(new, rb_gdbm_fetch3(obj, argv[i]));
|
rb_ary_push(new, rb_gdbm_fetch3(obj, argv[i]));
|
||||||
}
|
}
|
||||||
|
@ -360,6 +362,22 @@ fgdbm_select(argc, argv, obj)
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static VALUE
|
||||||
rb_gdbm_delete(obj, keystr)
|
rb_gdbm_delete(obj, keystr)
|
||||||
VALUE 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, "indexes", fgdbm_indexes, -1);
|
||||||
rb_define_method(rb_cGDBM, "indices", 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, "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, "length", fgdbm_length, 0);
|
||||||
rb_define_method(rb_cGDBM, "size", fgdbm_length, 0);
|
rb_define_method(rb_cGDBM, "size", fgdbm_length, 0);
|
||||||
rb_define_method(rb_cGDBM, "empty?", fgdbm_empty_p, 0);
|
rb_define_method(rb_cGDBM, "empty?", fgdbm_empty_p, 0);
|
||||||
|
|
|
@ -279,11 +279,11 @@ class TestGDBM < RUNIT::TestCase
|
||||||
assert_equals(values.reverse, @gdbm.indexes(*keys.reverse))
|
assert_equals(values.reverse, @gdbm.indexes(*keys.reverse))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_select
|
def test_values_at
|
||||||
keys = %w(foo bar baz)
|
keys = %w(foo bar baz)
|
||||||
values = %w(FOO BAR BAZ)
|
values = %w(FOO BAR BAZ)
|
||||||
@gdbm[keys[0]], @gdbm[keys[1]], @gdbm[keys[2]] = values
|
@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
|
end
|
||||||
|
|
||||||
def test_select_with_block
|
def test_select_with_block
|
||||||
|
|
|
@ -242,6 +242,8 @@ fsdbm_select(argc, argv, obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
rb_warn("SDBM#select(index..) is deprecated; use SDBM#values_at");
|
||||||
|
|
||||||
for (i=0; i<argc; i++) {
|
for (i=0; i<argc; i++) {
|
||||||
rb_ary_push(new, fsdbm_fetch(obj, argv[i], Qnil));
|
rb_ary_push(new, fsdbm_fetch(obj, argv[i], Qnil));
|
||||||
}
|
}
|
||||||
|
@ -250,6 +252,22 @@ fsdbm_select(argc, argv, obj)
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static VALUE
|
||||||
fsdbm_delete(obj, keystr)
|
fsdbm_delete(obj, keystr)
|
||||||
VALUE 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, "indexes", fsdbm_indexes, -1);
|
||||||
rb_define_method(rb_cDBM, "indices", 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, "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, "length", fsdbm_length, 0);
|
||||||
rb_define_method(rb_cDBM, "size", fsdbm_length, 0);
|
rb_define_method(rb_cDBM, "size", fsdbm_length, 0);
|
||||||
rb_define_method(rb_cDBM, "empty?", fsdbm_empty_p, 0);
|
rb_define_method(rb_cDBM, "empty?", fsdbm_empty_p, 0);
|
||||||
|
|
|
@ -51,7 +51,7 @@ class TestSDBM < RUNIT::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_version
|
def test_version
|
||||||
STDERR.print SDBM::VERSION
|
assert(! SDBM.const_defined?(:VERSION))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_s_new_has_no_block
|
def test_s_new_has_no_block
|
||||||
|
@ -219,11 +219,11 @@ class TestSDBM < RUNIT::TestCase
|
||||||
assert_equals(values.reverse, @sdbm.indexes(*keys.reverse))
|
assert_equals(values.reverse, @sdbm.indexes(*keys.reverse))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_select
|
def test_values_at
|
||||||
keys = %w(foo bar baz)
|
keys = %w(foo bar baz)
|
||||||
values = %w(FOO BAR BAZ)
|
values = %w(FOO BAR BAZ)
|
||||||
@sdbm[keys[0]], @sdbm[keys[1]], @sdbm[keys[2]] = values
|
@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
|
end
|
||||||
|
|
||||||
def test_select_with_block
|
def test_select_with_block
|
||||||
|
|
4
hash.c
4
hash.c
|
@ -533,13 +533,15 @@ rb_hash_select(argc, argv, hash)
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
if (!rb_block_given_p()) {
|
if (!rb_block_given_p()) {
|
||||||
|
#if RUBY_VERSION_CODE < 181
|
||||||
rb_warn("Hash#select(key..) is deprecated; use Hash#values_at");
|
rb_warn("Hash#select(key..) is deprecated; use Hash#values_at");
|
||||||
|
#endif
|
||||||
return rb_hash_values_at(argc, argv, hash);
|
return rb_hash_values_at(argc, argv, hash);
|
||||||
}
|
}
|
||||||
result = rb_ary_new();
|
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc);
|
rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc);
|
||||||
}
|
}
|
||||||
|
result = rb_ary_new();
|
||||||
rb_hash_foreach(hash, select_i, result);
|
rb_hash_foreach(hash, select_i, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -905,14 +905,14 @@ num_step(argc, argv, from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (TYPE(from) == T_FLOAT || TYPE(to) == T_FLOAT || TYPE(step) == T_FLOAT) {
|
else if (TYPE(from) == T_FLOAT || TYPE(to) == T_FLOAT || TYPE(step) == T_FLOAT) {
|
||||||
const double epsilon = DBL_EPSILON;
|
const double epsilon = DBL_EPSILON * 2;
|
||||||
double beg = NUM2DBL(from);
|
double beg = NUM2DBL(from);
|
||||||
double end = NUM2DBL(to);
|
double end = NUM2DBL(to);
|
||||||
double unit = NUM2DBL(step);
|
double unit = NUM2DBL(step);
|
||||||
double n = (end - beg)/unit;
|
double n = (end - beg)/unit;
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
n = floor(n + n*epsilon + 1);
|
n = floor(n + n*epsilon) + 1;
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
rb_yield(rb_float_new(i*unit+beg));
|
rb_yield(rb_float_new(i*unit+beg));
|
||||||
}
|
}
|
||||||
|
|
12
object.c
12
object.c
|
@ -904,13 +904,23 @@ rb_obj_methods(argc, argv, obj)
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE obj;
|
VALUE obj;
|
||||||
{
|
{
|
||||||
|
retry:
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
VALUE args[1];
|
VALUE args[1];
|
||||||
|
|
||||||
args[0] = Qtrue;
|
args[0] = Qtrue;
|
||||||
return rb_class_instance_methods(1, args, CLASS_OF(obj));
|
return rb_class_instance_methods(1, args, CLASS_OF(obj));
|
||||||
}
|
}
|
||||||
return rb_class_instance_methods(argc, argv, CLASS_OF(obj));
|
else {
|
||||||
|
VALUE recur;
|
||||||
|
|
||||||
|
rb_scan_args(argc, argv, "1", &recur);
|
||||||
|
if (RTEST(recur)) {
|
||||||
|
argc = 0;
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
return rb_obj_singleton_methods(argc, argv, obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
5
re.c
5
re.c
|
@ -990,6 +990,9 @@ match_select(argc, argv, match)
|
||||||
rb_warn("MatchData#select(index..) is deprecated; use MatchData#values_at");
|
rb_warn("MatchData#select(index..) is deprecated; use MatchData#values_at");
|
||||||
return match_values_at(argc, argv, match);
|
return match_values_at(argc, argv, match);
|
||||||
}
|
}
|
||||||
|
if (argc > 0) {
|
||||||
|
rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
struct re_registers *regs = RMATCH(match)->regs;
|
struct re_registers *regs = RMATCH(match)->regs;
|
||||||
VALUE target = RMATCH(match)->str;
|
VALUE target = RMATCH(match)->str;
|
||||||
|
@ -1000,7 +1003,7 @@ match_select(argc, argv, match)
|
||||||
for (i=0; i<regs->num_regs; i++) {
|
for (i=0; i<regs->num_regs; i++) {
|
||||||
VALUE str = rb_str_substr(target, regs->beg[i], regs->end[i]-regs->beg[i]);
|
VALUE str = rb_str_substr(target, regs->beg[i], regs->end[i]-regs->beg[i]);
|
||||||
if (taint) OBJ_TAINT(str);
|
if (taint) OBJ_TAINT(str);
|
||||||
if (rb_yield(str)) {
|
if (RTEST(rb_yield(str))) {
|
||||||
rb_ary_push(result, str);
|
rb_ary_push(result, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
struct.c
2
struct.c
|
@ -541,6 +541,8 @@ rb_struct_values_at(argc, argv, s)
|
||||||
for (i=0; i<argc; i++) {
|
for (i=0; i<argc; i++) {
|
||||||
rb_ary_push(result, rb_struct_aref(s, argv[i]));
|
rb_ary_push(result, rb_struct_aref(s, argv[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
Загрузка…
Ссылка в новой задаче